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 String getAndroidId(Context context) {
    String android_id = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);
    return android_id;
}

From source file:Main.java

public static void setAutoRoate(Context context, boolean enabled) {
    Settings.System.putInt(context.getContentResolver(), Settings.System.ACCELEROMETER_ROTATION,
            enabled ? 1 : 0);/*w  w  w.j a  v a 2  s  .  c  o m*/
}

From source file:Main.java

public static String getApnPort(Context context) {
    Cursor c = context.getContentResolver().query(PREFERRED_APN_URI, null, null, null, null);
    c.moveToFirst();//from   w w w.  ja  v a 2  s .  com
    if (c.isAfterLast()) {
        c.close();
        return "80";
    }

    String port = null;
    port = c.getString(c.getColumnIndex(APN_PROP_PORT));
    if (port == null) {
        c.close();
        port = "80";
    }
    c.close();
    return port;
}

From source file:Main.java

public static boolean isRunningOnEmulator(Context ctx) {
    if (Secure.getString(ctx.getContentResolver(), Secure.ANDROID_ID) == null) {
        return true;
    } else {/* w ww  .j  a  va  2s.c o m*/
        return false;
    }
}

From source file:Main.java

public static boolean setScreenDormantTime(Context context, int millis) {
    return Settings.System.putInt(context.getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, millis);
}

From source file:Main.java

public static String getMachineId(Context context) {

    String machineId = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);
    return machineId;

}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static void setBrightness(Context context, int brightness) {
    ContentResolver cResolver = context.getContentResolver();
    Settings.System.putInt(cResolver, Settings.System.SCREEN_BRIGHTNESS, brightness);
}

From source file:Main.java

/**
 * Retrieves an image's stream by an URI object.
 * @param context The context of the activity.
 * @param uri The URI object./*from   w ww .  j a  v a  2s  . c o m*/
 * @return The InputStream of the URI object.
 */
public static InputStream fetchImage(Context context, Uri uri) throws IOException {
    return context.getContentResolver().openInputStream(uri);
}