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);
    if (android_id != null) {
        return android_id;
    }//from  w  w  w .j  a  va2s .c  o  m
    return "";
}

From source file:Main.java

public static String getVideoPath(Context context, Intent data) {
    Cursor cursor = context.getContentResolver().query(data.getData(), null, null, null, null);
    if (cursor != null && cursor.moveToNext()) {
        String filePath = cursor.getString(cursor.getColumnIndex(VideoColumns.DATA));
        return filePath;
    } else if (data != null && data.getData() != null) {
        return data.getData().getEncodedPath();
    }//from  w w w.  ja v  a 2 s . c o  m
    return null;
}

From source file:Main.java

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

From source file:Main.java

public static InputStream getInputStreamByUri(Context context, Uri uri) {
    try {/*from  w ww.j  av  a 2s. c  o  m*/
        return context.getContentResolver().openInputStream(uri);
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}

From source file:Main.java

public static boolean isAirplaneModeEnabled(Context context) {
    boolean isEnabled = Settings.System.getInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON,
            0) == 1;/*ww w  . jav a2s .c  om*/
    return isEnabled;
}

From source file:Main.java

public static void setBrightnessMode(Context context, int brightnessMode) {
    Settings.System.putInt(context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE,
            brightnessMode);//from  w w w .j  a  va 2s . c  om
}

From source file:Main.java

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

From source file:Main.java

public static boolean isPhoneNumberInContactList(Context context, String phoneNumber) {

    Cursor c = context.getContentResolver().query(Phone.CONTENT_URI, new String[] { Phone.DATA4 },
            Phone.DATA4 + " = ? or " + Phone.DATA1 + " = ?", new String[] { phoneNumber, phoneNumber }, null);

    boolean result = c.moveToFirst();
    c.close();//from www  .j  ava2 s. co m

    return result;
}

From source file:Main.java

@SuppressWarnings("deprecation")
private static void closeBelowApiLevel17(Context context) throws Exception {
    Settings.System.putInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0);
    Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
    intent.putExtra("state", false);
    context.sendBroadcast(intent);/*from w  w w.  j a  va  2  s . c  o  m*/
}

From source file:Main.java

public static boolean isAirplaneModeEnabled(Context context) {
    boolean isEnabled = Settings.System.getInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON,
            0) == AIRPLANE_MODE_ON;//w ww  .j a  v a2  s  .c om
    return isEnabled;
}