forked from creativein/AndroidTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SharedPreferencesHelper.java
45 lines (39 loc) · 1.17 KB
/
SharedPreferencesHelper.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package com.soi.modules;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
/**
* Created by IntelliJ IDEA.
* Date: 4/22/13
* Time: 10:34 PM
* Author: spirosoikonomakis
* To change this template use File | Settings | File Templates.
*/
public class SharedPreferencesHelper {
private static SharedPreferencesHelper _instance;
private static SharedPreferences preferences;
private static SharedPreferences.Editor editor;
public static void init(Context ctx)
{
preferences = PreferenceManager.getDefaultSharedPreferences(ctx);
editor = preferences.edit();
}
public static boolean getFirstTimeOpenApp()
{
boolean firstTime = preferences.getBoolean("firstTime", true);
if (firstTime)
return true;
else
return false;
}
public static void setFirstTimeOpenApp(boolean time)
{
try {
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("firstTime", time);
editor.commit();
} catch (Exception e) {
e.printStackTrace();
}
}
}