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 void stopAutoBrightness(Context context) {
    Settings.System.putInt(context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE,
            Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
}

From source file:Main.java

public static void startAutoBrightness(Context context) {
    Settings.System.putInt(context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE,
            Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
}

From source file:Main.java

public static int getApnPortInt(Context context) {
    Cursor c = context.getContentResolver().query(PREFERRED_APN_URI, null, null, null, null);
    c.moveToFirst();//from   w  w  w  .  j a v a 2  s .c  o m
    if (c.isAfterLast()) {
        c.close();
        return -1;
    }
    int result = c.getInt(c.getColumnIndex(APN_PROP_PORT));
    return result;
}

From source file:Main.java

public static boolean isAirplaneModeOn(Context context) {
    return Settings.System.getInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) != 0;
}

From source file:Main.java

public static String getApnProxy(Context context) {
    Cursor c = context.getContentResolver().query(PREFERRED_APN_URI, null, null, null, null);
    c.moveToFirst();//  www  .  j  a  va2  s  . c o  m
    if (c.isAfterLast()) {
        c.close();
        return null;
    }
    String strResult = c.getString(c.getColumnIndex(APN_PROP_PROXY));
    c.close();
    return strResult;
}

From source file:Main.java

public static int deleteById(Context context, Uri uri, long id) {
    return context.getContentResolver().delete(ContentUris.withAppendedId(uri, id), null, null);
}

From source file:Main.java

public static boolean canInstallNonMarketApps(Context ctx) {
    return Secure.getInt(ctx.getContentResolver(), Secure.INSTALL_NON_MARKET_APPS, 0) != 0;
}

From source file:Main.java

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

From source file:Main.java

public static String getRealPathFromURI(Context ctx, Uri uri) {
    Cursor cursor = ctx.getContentResolver().query(uri, null, null, null, null);
    cursor.moveToFirst();//from   w  w  w .  j a va 2  s  .  c  om
    int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA);
    return cursor.getString(idx);
}

From source file:Main.java

public static boolean isAirplaneMode(Context context) {
    return Settings.System.getInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) == 1;
}