Code example for Context

Methods: getPackageName

0
	public static String getPackageVersionName(final Context pContext) {
		return SystemUtils.getPackageInfo(pContext).versionName;
	} 
 
	public static String getPackageName(final Context pContext) {
		return pContext.getPackageName();
	} 
 
	public static String getApkFilePath(final Context pContext) throws NameNotFoundException {
		final PackageManager packMgmr = pContext.getPackageManager();
		return packMgmr.getApplicationInfo(SystemUtils.getPackageName(pContext), 0).sourceDir;
	} 
 
	private static PackageInfo getPackageInfo(final Context pContext) {
		try { 
			return pContext.getPackageManager().getPackageInfo(pContext.getPackageName(), 0);
		} catch (final NameNotFoundException e) {
			Debug.e(e);
			return null; 
		} 
	}