12

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?

HitOdessit
  • 7,198
  • 4
  • 36
  • 59
Savvas Dalkitsis
  • 11,476
  • 16
  • 65
  • 104

2 Answers2

7

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..

Yahia
  • 69,653
  • 9
  • 115
  • 144
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).

JohnyTex
  • 3,323
  • 5
  • 29
  • 52
  • This comes from the `Settings.BACKUP_ENABLED` constant, which is marked as `@UnsupportedAppUsage` as of Version R, so won't work on newer phones – Merk Oct 25 '22 at 01:36