Android SharedPreferences Get asyncCommit( final SharedPreferences.Editor editor)

Here you can find the source of asyncCommit( final SharedPreferences.Editor editor)

Description

async Commit

Declaration

public static synchronized void asyncCommit(
            final SharedPreferences.Editor editor) 

Method Source Code

//package com.java2s;

import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Build;

public class Main {
    public static synchronized void asyncCommit(
            final SharedPreferences.Editor editor) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
            editor.apply();//from  w w w. ja v  a  2 s. com
        } else {
            new AsyncTask<Void, Void, Void>() {
                @Override
                protected Void doInBackground(Void... params) {
                    editor.commit();
                    return null;
                }
            }.execute();
        }
    }
}

Related

  1. getPrefInt(Context c, String key, int defValue)
  2. getPrefString(Context c, String key, String defValue)
  3. getSaltFromPreferences(SharedPreferences prefs)
  4. getPinHashFromPreferences(SharedPreferences prefs)
  5. isRegistrationExpired(SharedPreferences prefs)