Java tutorial
//package com.java2s; import android.content.Context; import android.content.SharedPreferences; public class Main { private static final String PREF_FILE_NAME = "andialog_rate_pref_file"; private static final String PREF_KEY_LAUNCH_TIMES = "andialog_rate_launch_times"; /** * set luanch times date. * If launch time is over than setting times, rate dialog will appear. * * @param context context * @param launchTimes launchTimes */ static void setLaunchTimes(Context context, int launchTimes) { SharedPreferences.Editor editor = getPreferencesEditor(context); editor.putInt(PREF_KEY_LAUNCH_TIMES, launchTimes); editor.apply(); } static SharedPreferences.Editor getPreferencesEditor(Context context) { return getPreferences(context).edit(); } static SharedPreferences getPreferences(Context context) { return context.getSharedPreferences(PREF_FILE_NAME, Context.MODE_PRIVATE); } }