Skip to content

Instantly share code, notes, and snippets.

@mttkay
Created October 8, 2012 08:40
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mttkay/3851440 to your computer and use it in GitHub Desktop.
Save mttkay/3851440 to your computer and use it in GitHub Desktop.
Testing if an Android app is installed on the SD card
private boolean isAppInstalledToSDCard(Context context) {
PackageManager pm = context.getPackageManager();
try {
int extStorage = ApplicationInfo.FLAG_EXTERNAL_STORAGE;
String package = context.getPackageName();
ApplicationInfo appInfo = pm.getApplicationInfo(package, extStorage);
return extStorage == (extStorage & appInfo.flags);
} catch (NameNotFoundException e) {
e.printStackTrace();
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment