Android BackupAgent does not support backup / restore of sharedpreferences

I am trying to use BackupAgent to backup default sharedpreferences . This is what I have for MyBackupAgent

 public class MyBackupAgent extends BackupAgentHelper { // The name of the SharedPreferences file private final String PREFS = "com.mikebdev.refuelpro_preferences"; // A key to uniquely identify the set of backup data private static final String PREFS_BACKUP_KEY = "prefs"; @Override public void onCreate() { SharedPreferencesBackupHelper sharedPref = new SharedPreferencesBackupHelper(this, PREFS); addHelper(PREFS_BACKUP_KEY, sharedPref); } } 

When I force backup and restore from ADB, this is what I get in the console:

 shell@flo :/ $ bmgr backup com.mikebdev.refuelpro bmgr backup com.mikebdev.refuelpro shell@flo :/ $ bmgr backup run bmgr backup run shell@flo :/ $ bmgr restore com.mikebdev.refuelpro bmgr restore com.mikebdev.refuelpro restoreStarting: 2 packages restoreFinished: 0 done 

This is what Logcat has to say:

 09-20 18:47:32.125 525-539/? I/BackupManagerService﹕ Scheduling backup for new app com.mikebdev.refuelpro 09-20 18:47:32.125 525-539/? D/BackupManagerService﹕ Now staging backup of com.mikebdev.refuelpro 09-20 18:47:32.966 525-2458/? D/BackupManagerService﹕ agentConnected pkg=com.mikebdev.refuelpro agent=android.os.BinderProxy@42222800 09-20 18:52:00.336 525-539/? D/BackupManagerService﹕ Received broadcast Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:com.mikebdev.refuelpro flg=0x8000010 (has extras) } 09-20 18:52:00.336 525-539/? V/BackupManagerService﹕ removePackageParticipantsLocked: uid=10084 #1 09-20 18:52:08.344 525-546/? V/BackupManagerService﹕ restoreAtInstall pkg=com.mikebdev.refuelpro token=f restoreSet=39fa49811177c60b 09-20 18:52:08.354 525-657/? D/BackupManagerService﹕ MSG_RUN_RESTORE observer=null 09-20 18:52:08.935 525-657/? D/BackupManagerService﹕ initiateOneRestore packageName=@pm @ 09-20 18:52:08.945 525-657/? V/BackupServiceBinder﹕ doRestore() invoked 09-20 18:52:08.945 525-657/? V/BackupManagerService﹕ No next package, finishing restore 09-20 18:52:08.945 525-657/? I/BackupManagerService﹕ Restore complete. 

So now I wonder what happens while I have no idea. I do not know why this will not work.

And how exactly can I back up my SQLite database with this service?

early

+6
source share

Source: https://habr.com/ru/post/954278/


All Articles