Determine if system wide backup is enabled programmatically
Asked Answered
G

2

11

I was wondering if it possible to determine if the user has enabled the option to backup application data to the cloud from within my android app.

I can determine this from the command line, from adb shell by calling:

bmgr enabled

Does android provide an API to do so from code?

Ghoul answered 29/9, 2011 at 10:9 Comment(0)
P
6

According to http://developer.android.com/guide/developing/tools/bmgr.html there is no API to do what you ask - only interfaces an app can implement to interact with the BackupManager regarding its data backup/restore..

Periostitis answered 8/11, 2011 at 21:56 Comment(0)
S
0
try {
    int backups_enabled = Settings.Secure.getInt(getApplicationContext().getContentResolver(), "backup_enabled");
    Log.i("TAG", "Backups are "+(backups_enabled == 1 ? "enabled" : "disabled"));
} catch (Settings.SettingNotFoundException e) {
    Log.e("TAG", "Setting not found", e);
}

Note: In order for backups to work, the device also needs to be provisioned (Settings.Global.DEVICE_PROVISIONED).

Suborder answered 19/11, 2021 at 10:49 Comment(1)
This comes from the Settings.BACKUP_ENABLED constant, which is marked as @UnsupportedAppUsage as of Version R, so won't work on newer phonesTranslucent

© 2022 - 2024 — McMap. All rights reserved.