List of usage examples for android.content Context getContentResolver
public abstract ContentResolver getContentResolver();
From source file:Main.java
public static int getOrientation(Context context, Uri contentUri) { Cursor cursor = context.getContentResolver().query(contentUri, new String[] { MediaStore.Images.ImageColumns.ORIENTATION }, null, null, null); try {/* w ww . j a va2 s. co m*/ if (cursor.moveToFirst()) { return cursor.getInt(0); } else { return -1; } } finally { cursor.close(); } }
From source file:Main.java
/** * Is Roaming enabled.// w w w . j a v a 2 s. c o m * * @return */ @SuppressWarnings("deprecation") private static boolean isRoamingEnabled(Context ctx) { ContentResolver cr = ctx.getContentResolver(); int result = 0; // 0 is false boolean check = false; try { result = Settings.Secure.getInt(cr, Settings.Secure.DATA_ROAMING); } catch (SettingNotFoundException e) { e.printStackTrace(); } if (result == 1) { check = true; } return check; }
From source file:Main.java
@SuppressWarnings("deprecation") private static String getDebugAppPreJBMR1(Context context) { boolean adbEnabled = Settings.System.getInt(context.getContentResolver(), Settings.System.ADB_ENABLED, 0) == 1;/* ww w . j a v a 2s .com*/ if (adbEnabled) { return Settings.System.getString(context.getContentResolver(), Settings.System.DEBUG_APP); } return null; }
From source file:Main.java
/** * @returns true if the device is provisioned, and we're past the point where device owner can * be installed//w w w . j a v a 2 s . c om */ public static boolean isDeviceProvisioned(Context context) { ContentResolver contentResolver = context.getContentResolver(); return Settings.Global.getInt(contentResolver, Settings.Global.DEVICE_PROVISIONED, 0) != 0; }
From source file:Main.java
public static String getDeviceId(Context context) { try {//from w w w . j a v a 2 s. c o m return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); } catch (Exception e) { return ""; } }
From source file:Main.java
/** * This method to get real path from uri. * /* ww w.j av a2 s. c o m*/ * @param context * @param contentURI * @return imagepath */ public static String getRealPathFromURI(Context context, Uri contentURI) { Cursor cursor = context.getContentResolver().query(contentURI, null, null, null, null); if (cursor == null) { return contentURI.getPath(); } else { cursor.moveToFirst(); int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA); return cursor.getString(idx); } }
From source file:Main.java
@SuppressLint("NewApi") private static String getDebugAppJBMR1(Context context) { boolean adbEnabled = Settings.Global.getInt(context.getContentResolver(), Settings.Global.ADB_ENABLED, 0) == 1;//from w w w .j a v a2s . c o m if (adbEnabled) { return Settings.Global.getString(context.getContentResolver(), Settings.Global.DEBUG_APP); } return null; }
From source file:Main.java
public static Bundle getContactFromNumber(String number, Context context) { ContentResolver cr = context.getContentResolver(); String[] projection = new String[] { Contacts._ID, Contacts.DISPLAY_NAME }; Bundle bundle = new Bundle(); Uri contactUri = Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI, Uri.encode(number)); Cursor cursor = cr.query(contactUri, projection, null, null, null); try {/*from w ww . j a v a 2 s .c om*/ if (cursor.moveToFirst()) { for (String key : projection) { bundle.putString(key, cursor.getString(cursor.getColumnIndex(key))); } } return bundle; } catch (Exception e) { return null; } finally { cursor.close(); } }
From source file:Main.java
public static boolean isAirplaneModeOn(Context ctx) { boolean isModeOn; isModeOn = Settings.System.getInt(ctx.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) != 0; return isModeOn; }
From source file:Main.java
public static String getDeviceId(Context context) { String android_id = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); if (android_id != null) { return android_id; } else {//from w w w. jav a2 s . c o m return ""; } }