FileDocCategorySizeDatePackage
SharedPreferencesCompat.javaAPI DocAndroid 5.1 API1656Thu Mar 12 22:22:48 GMT 2015com.android.common

SharedPreferencesCompat

public class SharedPreferencesCompat extends Object
Reflection utils to call SharedPreferences$Editor.apply when possible, falling back to commit when apply isn't available.

Fields Summary
private static Method
sApplyMethod
Constructors Summary
Methods Summary
public static voidapply(SharedPreferences.Editor editor)

        try {
            Class cls = SharedPreferences.Editor.class;
            sApplyMethod = cls.getMethod("apply");
        } catch (NoSuchMethodException unused) {
            sApplyMethod = null;
        }
    
        if (sApplyMethod != null) {
            try {
                sApplyMethod.invoke(editor);
                return;
            } catch (InvocationTargetException unused) {
                // fall through
            } catch (IllegalAccessException unused) {
                // fall through
            }
        }
        editor.commit();