문제

I am implementing the new BackupAgentHelper from Android OS 2.2.

For it to work you need to supply the name of the SharedPreferences that you want to backup:

public class MyPrefsBackupAgent extends BackupAgentHelper {
// The name of the SharedPreferences file
static final String PREFS = "user_preferences";

// A key to uniquely identify the set of backup data
static final String PREFS_BACKUP_KEY = "prefs";

// Allocate a helper and add it to the backup agent
void onCreate() {
    SharedPreferencesBackupHelper helper = new SharedPreferencesBackupHelper(this, PREFS);
    addHelper(PREFS_BACKUP_KEY, helper);
}
}

Problem is I use the PreferenceManager.getDefaultSharedPreferences() method in my application to get the default shared preferences instance. Now I need to supply the name of that file. How can I find out what name that is?

(And why do they not supply a helper that just does a DefaultSharedPreferences backup?)

도움이 되었습니까?

해결책

It looks like it's called "packagename_preferences"

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top