Java tutorial
//package com.java2s; import android.content.Context; import android.content.SharedPreferences; import android.util.Log; public class Main { private final static String SHARED_PREFERENCE_NAME = "SC_SHARED_PREFERENCE"; public static boolean getBooleanPreferences(Context context, String name) { try { return context.getSharedPreferences(SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE).getBoolean(name, false); } catch (Exception e) { Log.e("datautils", e.getMessage()); remove(context, name); } return false; } public static void remove(Context context, String name) { try { SharedPreferences.Editor editor = context .getSharedPreferences(SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE).edit(); editor.remove(name); editor.commit(); } catch (Exception e) { Log.e("datautils", e.getMessage() + ""); } } }