Example usage for android.content Context getContentResolver

List of usage examples for android.content Context getContentResolver

Introduction

In this page you can find the example usage for android.content Context getContentResolver.

Prototype

public abstract ContentResolver getContentResolver();

Source Link

Document

Return a ContentResolver instance for your application's package.

Usage

From source file:Main.java

public static boolean isHourto24(Context context) {
    ContentResolver cr = context.getContentResolver();
    String strFormatTime = android.provider.Settings.System.getString(cr,
            android.provider.Settings.System.TIME_12_24);
    if (null != strFormatTime && strFormatTime.equals("24")) {
        return true;
    } else {//from w  ww.  j  a  v a  2 s  .  c o  m
        return false;
    }
}

From source file:Main.java

public static String getRealDeviceId(Context context) {
    return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
}

From source file:Main.java

public static String getAndroidID(Context context) {
    return Settings.Secure.getString(context.getContentResolver(), "android_id");
}

From source file:Main.java

public static boolean deleteArtwork(Context c, long albumId) {
    return c.getContentResolver().delete(ContentUris.withAppendedId(ARTWORK_URI, albumId), null, null) > 0;
}

From source file:Main.java

public static String getClientId(Context context) {

    return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
}

From source file:Main.java

public static String query(Context context, Uri uri) {
    Cursor cursor = context.getContentResolver().query(uri, new String[] { MediaColumns.DATA }, null, null,
            null);//from   w ww  .  jav  a  2s.  c o m
    cursor.moveToNext();
    return cursor.getString(cursor.getColumnIndex(MediaColumns.DATA));
}

From source file:Main.java

public static int delete(Context context, Uri uri, String where) {
    return context.getContentResolver().delete(uri, where, null);
}

From source file:Main.java

public static String getDeviceId(Context ctx) {
    return Secure.getString(ctx.getContentResolver(), ANDROID_ID);
}

From source file:Main.java

/**
 * Helper method to reslove a uri into a path.
 * /*from  ww w  .  jav  a  2  s. com*/
 * @param contentURI
 *            a uri path
 * @return the path as a string
 */
public static String getRealPathFromURI(Uri contentURI, Context context) {
    Cursor cursor = context.getContentResolver().query(contentURI, null, null, null, null);
    cursor.moveToFirst();
    int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA);
    String path = cursor.getString(idx);
    cursor.close();
    return path;
}

From source file:Main.java

/**
 * Checks to see if the user has rotation enabled/disabled in their phone settings.
 *
 * @param context The current Context or Activity that this method is called from
 * @return true if rotation is enabled, otherwise false.
 *//*from w ww .ja  va 2  s. c o  m*/
public static boolean isRotationEnabled(Context context) {
    return Settings.System.getInt(context.getContentResolver(), Settings.System.ACCELEROMETER_ROTATION, 0) == 1;
}