| WHAT We should expose a function that allows the end developer to check if the backup flag is enabled in the application . HOW We can use PackageInfo to check if the flag is enabled.
public void detectBackupEnabled() { |
totalTests++; |
try { |
PackageInfo packageInfo; |
packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); |
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_ALLOW_BACKUP) != 0) { |
setDetected(allowBackup, R.string.allow_backup_detected_positive); |
} |
} catch (PackageManager.NameNotFoundException e) { |
e.printStackTrace(); |
} |
}
|
|