List of usage examples for android.content Context getPackageName
public abstract String getPackageName();
From source file:Main.java
/** * Get application meta-data of the current package name. * @param context application context./* ww w .j ava 2s. c om*/ * @return meta-data, may be empty but never null. */ public static Bundle getMetaData(Context context) { return getMetaData(context, context.getPackageName()); }
From source file:Main.java
public static String getApplicationVersion(Context ctx) { try {/*w ww . ja v a2s.co m*/ return ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0).versionName; } catch (PackageManager.NameNotFoundException e) { Log.d(TAG, "", e); return null; } }
From source file:Main.java
public static String getVerName(Context c) { String verName = ""; try {//from w w w . j a va2 s . c o m String packageName = c.getPackageName(); verName = c.getPackageManager().getPackageInfo(packageName, 0).versionName; } catch (PackageManager.NameNotFoundException e) { } return verName; }
From source file:Main.java
static public int getIdResource(Context ctx, String name) { return ctx.getResources().getIdentifier(name, "id", ctx.getPackageName()); }
From source file:Main.java
public static String getVersionName(Context context) { try {//from ww w .j a v a2s. c o m return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (Exception e) { return null; } }
From source file:Main.java
public static int getIconId(Context context, String name) { return context.getResources().getIdentifier(name, "drawable", context.getPackageName()); }
From source file:Main.java
public static File getStoragePath(Context ctx, String directory) { return new File(Environment.getExternalStorageDirectory(), ctx.getPackageName() + "/" + directory); }
From source file:Main.java
public static int getResId(final String variableName, final Context context) { return context.getResources().getIdentifier(variableName, "drawable", context.getPackageName()); }
From source file:Main.java
public static void cleanSharedPreference(Context context, String sharedPreferenceName) { File file = new File("/data/data/" + context.getPackageName().toString() + "/shared_prefs", sharedPreferenceName);/*from w w w.j av a2 s.c o m*/ if (file.exists()) { file.delete(); } }
From source file:Main.java
private static boolean modifyPermission(Context context, int flag) { String packageName = context.getPackageName(); try {//from w w w. j a v a 2 s .c om ContentValues contentValues = new ContentValues(); contentValues.put("userAccept", Integer.valueOf(flag)); context.getContentResolver().update(Uri.parse("content://com.lbe.security.miui.permmgr/active"), contentValues, "pkgName=?", new String[] { packageName }); return true; } catch (Exception e) { e.printStackTrace(); return false; } }