Code example for Context

Methods: getContentResolver

0
     *            the context 
     * @return the device's ANDROID_ID, or null if it could not be determined 
     * @see Secure#ANDROID_ID 
     */ 
    public static String getAndroidId(Context context) {
        String androidId = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);
        if (androidId == null) {
            // this happens on 1.6 and older 
            androidId = android.provider.Settings.System.getString(context.getContentResolver(),
                    android.provider.Settings.System.ANDROID_ID);
        } 
        return androidId;
    } 
 
    /** 
     * Same as {@link #getAndroidId(Context)}, but never returns null. 
     *  
     * @param context 
     *            the context 
     * @param fallbackValue 
     *            the fallback value