Code example for SharedPreferences

Methods: editgetBooleangetLong

0
	 * Call this method at the end of your OnCreate method to determine whether 
	 * to show the rate prompt 
	 */ 
	public static void app_launched(Context context) {
		SharedPreferences prefs = context.getSharedPreferences("apprater", 0);
		if (prefs.getBoolean("dontshowagain", false)) {
			return; 
		} 
 
		SharedPreferences.Editor editor = prefs.edit();
 
		// Increment launch counter 
		long launch_count = prefs.getLong("launch_count", 0) + 1;
		editor.putLong("launch_count", launch_count);
 
		// Get date of first launch 
		Long date_firstLaunch = prefs.getLong("date_firstlaunch", 0);
		if (date_firstLaunch == 0) {
			date_firstLaunch = System.currentTimeMillis();
			editor.putLong("date_firstlaunch", date_firstLaunch);
		}