Last active
August 29, 2015 13:56
-
-
Save Trinea/9088549 to your computer and use it in GitHub Desktop.
get system install location
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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