List of usage examples for android.content Context getPackageName
public abstract String getPackageName();
From source file:Main.java
/** * Returns version name of OpenSudoku.//from w w w.j a va 2s . com * * @return */ public static String getAppVersionName(Context context) { try { return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (NameNotFoundException e) { throw new RuntimeException(e); } }
From source file:Main.java
/** * Returns version code of OpenSudoku./*from www. j a va 2 s . c o m*/ * * @return */ public static int getAppVersionCode(Context context) { try { return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; } catch (NameNotFoundException e) { throw new RuntimeException(e); } }
From source file:Main.java
public static String getString(Context context, String key) { if (sp == null) { sp = context.getSharedPreferences(context.getPackageName(), Activity.MODE_PRIVATE); }/*www . j a v a2 s .com*/ return sp.getString(key, ""); }
From source file:Main.java
public static int getInt(Context context, String key) { if (sp == null) { sp = context.getSharedPreferences(context.getPackageName(), Activity.MODE_PRIVATE); }//ww w. java2 s .c o m return sp.getInt(key, 0); }
From source file:Main.java
public static String getVersionName(Context context) { String verName = ""; try {/*from www . java 2 s . c om*/ String packageName = context.getPackageName(); verName = context.getPackageManager().getPackageInfo(packageName, 0).versionName; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return verName; }
From source file:Main.java
public static boolean contains(Context context, String key) { if (sp == null) { sp = context.getSharedPreferences(context.getPackageName(), Activity.MODE_PRIVATE); }// ww w.j a va2 s . c om return sp.contains(key); }
From source file:Main.java
public static int getVersionCode(Context context) { try {/* w w w.j ava2 s . c o m*/ return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; } catch (PackageManager.NameNotFoundException e) { out(e); } return -1; }
From source file:Main.java
public static String getVersionName(Context context) { String verName = ""; try {//from w ww . ja va 2s . c o m String packageName = context.getPackageName(); verName = context.getPackageManager().getPackageInfo(packageName, 0).versionName; } catch (NameNotFoundException e) { e.printStackTrace(); } return verName; }
From source file:Main.java
/** * Get the application package name./* ww w . j a va 2 s . c o m*/ * * @param context Context * @return package name */ public static String getPackageName(final Context context) { return context.getPackageName(); }
From source file:Main.java
/** * get version code//from w w w .jav a 2 s. co m */ public static int getVersionCode(Context context) { int verCode = -1; try { String packageName = context.getPackageName(); verCode = context.getPackageManager().getPackageInfo(packageName, 0).versionCode; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return verCode; }