Skip to content

Instantly share code, notes, and snippets.

@Trinea
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Trinea/9088549 to your computer and use it in GitHub Desktop.
Save Trinea/9088549 to your computer and use it in GitHub Desktop.
get system install location
/**
* get system install location<br/>
* can be set by System Menu Setting->Storage->Prefered install location
*
* @return
* @see {@link IPackageManager#getInstallLocation()}
*/
public static int getInstallLocation() {
CommandResult commandResult = ShellUtils.execCommand("LD_LIBRARY_PATH=/vendor/lib:/system/lib pm get-install-location",
false, true);
if (commandResult.result == 0 && commandResult.successMsg != null && commandResult.successMsg.length() > 0) {
try {
int location = Integer.parseInt(commandResult.successMsg.substring(0, 1));
switch (location) {
case APP_INSTALL_INTERNAL:
return APP_INSTALL_INTERNAL;
case APP_INSTALL_EXTERNAL:
return APP_INSTALL_EXTERNAL;
}
} catch (NumberFormatException e) {
e.printStackTrace();
Log.e(TAG, "pm get-install-location error");
}
}
return APP_INSTALL_AUTO;
}
the more see: https://github.com/Trinea/android-common/blob/master/src/cn/trinea/android/common/util/PackageUtils.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment