List of utility methods to do Context Get
String | getString(Context context, String key, String defValue) get String return getDefaultSharedPreferences(context)
.getString(key, defValue);
|
String | getString(Context context, int resourceId) get String if (context != null) { return context.getResources().getString(resourceId); return null; |
String | getStringFromResource(int resource, Context context) get String From Resource InputStream is = context.getResources().openRawResource(resource); BufferedReader br = new BufferedReader(new InputStreamReader(is)); String readLine = null; String contents = ""; try { while ((readLine = br.readLine()) != null) { contents += readLine + "\n"; is.close(); br.close(); } catch (IOException e) { e.printStackTrace(); return contents; |
int | getStringResourceByName(String aString, Context context) get String Resource By Name String packageName = context.getPackageName(); int resId = context.getResources().getIdentifier(aString, "string", packageName); return resId; |
File | getSystemDiskCacheDir(Context context) get System Disk Cache Dir final String cachePath = Environment.MEDIA_MOUNTED .equals(Environment.getExternalStorageState()) ? getExternalCacheDir( context).getPath() : context.getCacheDir().getPath(); return new File(cachePath); |
Typeface | getTCBoldFont(Context context) get TC Bold Font Typeface tf = Typeface.createFromAsset(context.getAssets(),
fontPath_bold);
return tf;
|
Typeface | getTCFont(Context context) get TC Font Typeface tf = Typeface.createFromAsset(context.getAssets(),
fontPath);
return tf;
|
Typeface | getTCItalicFont(Context context) get TC Italic Font Typeface tf = Typeface.createFromAsset(context.getAssets(),
fontPath_italic);
return tf;
|
File | getTempFile(Context context) get Temp File final File path = new File( Environment.getExternalStorageDirectory(), context.getPackageName()); if (!path.exists()) { path.mkdir(); return new File(path, "image.tmp"); |
String | getTimestamp(Context context) Return a timestamp String timestamp = "unknown"; Date now = new Date(); java.text.DateFormat dateFormat = android.text.format.DateFormat .getDateFormat(context); java.text.DateFormat timeFormat = android.text.format.DateFormat .getTimeFormat(context); if (dateFormat != null && timeFormat != null) { timestamp = dateFormat.format(now) + ' ' ... |