Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check android:allowBackup value programmatically

As I have studied about the security issues in Android, one good practice is to check if the allowBackup and backupAgent has been set in the AndroidManifest.xml.

How to check android:allowBackup value of an app programmatically?

like image 916
Farhad Faghihi Avatar asked Feb 28 '26 05:02

Farhad Faghihi


2 Answers



      PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
      if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_ALLOW_BACKUP) != 0) {
         // enabled
      } else {
         // disabled
      }


like image 134
azizbekian Avatar answered Mar 01 '26 18:03

azizbekian


Check out FLAG_ALLOW_BACKUP and the other related flags in ApplicationInfo.

like image 40
fattire Avatar answered Mar 01 '26 17:03

fattire