Here you can find the source of asyncCommit( final SharedPreferences.Editor editor)
public static synchronized void asyncCommit( final SharedPreferences.Editor editor)
//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(); } } }