Hello I created my first app with Android studio, I need to Backup /restore 
data each time user add new record to Database, but untill now 
requestBackup is not working. when I tested by : adb shell bmgr backup 
<package> adb shell bmgr run adb shell bmgr restore <package> It works, but 
not automaticly Here my files 
Manifest------------------------------------------------------------------------------------------------------------------------------------
 
<application android:allowBackup="true" 
android:backupAgent="TheBackupAgent" <meta-data 
android:name="com.google.android.backup.api_key" 
android:value="WWWWWWWWWWWWWWWWWWWWWWWW \> 
--------------------------------------------------------------------------------------------------------------------------------------------------
 
TheBackupAgent-----------------------------------------------------------------------------------------------------------------------
 
public class TheBackupAgent extends BackupAgentHelper { String 
DATABASE_NAME = "caisses"; String DATABASE_FILE_NAME = "caisses.db"; 
@Override public void onCreate() { FileBackupHelper dbs = new 
FileBackupHelper(this, DATABASE_FILE_NAME); addHelper("dbs", dbs); } 
@Override public File getFilesDir() { File path = 
getDatabasePath(DATABASE_FILE_NAME); return path.getParentFile(); } public 
static void requestBackup(Context context) { BackupManager bm = new 
BackupManager(context); bm.dataChanged(); } } 
--------------------------------------------------------------------------------------------------------------------------------------------------
 
Activity add Operation to 
database-------------------------------------------------------------------------------------------
 
mabase.insertOperation(id_client, id_type, IO, 
Integer.parseInt(date_en_chiffre.toString()), date.getText().toString()); 
Toast.makeText(getBaseContext(), "Enregistré avec succès, OK", 
Toast.LENGTH_SHORT).show(); 
TheBackupAgent.requestBackup(New_Operation.this); 

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/902a56eb-604b-4723-a0d5-a5fcbf05f04e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to