Android examples for App:App Running
Applies the editor changes if running on a build version where this method is available, else commits the changes.
//package com.java2s; import android.content.SharedPreferences; import android.os.Build; public class Main { /**//from w w w .j a va2 s .c om * Applies the editor changes if running on a build version where this method is available, else * commits the changes. * @param editor The editor which's changes are to be commited or applied. */ public static final void commitOrApplySharedPreferencesEditor( SharedPreferences.Editor editor) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { editor.apply(); } else { editor.commit(); } } }