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 getAndroidDeviceId(Context context) {

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

From source file:Main.java

public static String getAndroidId(Context context) {
    String androidId = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);

    return androidId;
}

From source file:Main.java

public static String getServicePhoneNum(Context context) {
    String service_phone = Settings.System.getString(context.getContentResolver(), "phone_service_number");
    return service_phone;
}

From source file:Main.java

public static Drawable changeLocalAvatar(Context context, Uri uri) {
    ContentResolver cr = context.getContentResolver();
    Bitmap bitmap = null;/*from  w w w.  j  a  v  a 2  s  .  co m*/
    try {
        bitmap = BitmapFactory.decodeStream(cr.openInputStream(uri));
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    return new BitmapDrawable(bitmap);
}

From source file:Main.java

public static String getDeviceId(Context context) {

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

}

From source file:Main.java

/**
 * is air plane mode?//from   w  w w  .  j  a v a  2  s.  c  o  m
 * @param context
 * @return
 */
public static boolean isAirplaneModeOn(Context context) {
    return android.provider.Settings.System.getInt(context.getContentResolver(),
            android.provider.Settings.System.AIRPLANE_MODE_ON, 0) != 0;
}

From source file:Main.java

protected static boolean isMobileDataEnabledInSettings(final Context context) {
    return 1 == Settings.Secure.getInt(context.getContentResolver(), "mobile_data", 1);
}

From source file:Main.java

private static long getFileId(Context context, Uri fileUri) {

    Cursor cursor = context.getContentResolver().query(fileUri, mediaColumns, null, null, null);

    if (cursor.moveToFirst()) {
        int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Video.Media._ID);
        int id = cursor.getInt(columnIndex);
        return id;
    }// w  ww.  ja v  a  2s . co  m

    return 0;
}

From source file:Main.java

/**
 * Get device unique identify./*  ww w.  j av  a2s.co m*/
 *
 * @param context
 */
public static String getDeviceId(Context context) {
    String androidId = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);
    // If android_id is null , then use serial number.
    if (androidId == null) {
        androidId = Build.SERIAL;
    }
    return androidId;
}

From source file:Main.java

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