Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.content.SharedPreferences; public class Main { public static SharedPreferences sharedPreferences; public static boolean getIsOpenFirst(Context context) { if (sharedPreferences == null) { sharedPreferences = context.getSharedPreferences("led", Context.MODE_PRIVATE); return true; } sharedPreferences.getString("led", null); return false; } public static String getString(Context context, String key, String defvalue) { if (sharedPreferences == null) { sharedPreferences = context.getSharedPreferences("Cache", Context.MODE_PRIVATE); } String a = sharedPreferences.getString(key, defvalue); return a; } }