-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMySharePref.java
More file actions
25 lines (19 loc) · 836 Bytes
/
MySharePref.java
File metadata and controls
25 lines (19 loc) · 836 Bytes
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
import android.content.Context;
import android.content.SharedPreferences;
/**
* Created by HUNGDH on 5/18/2017.
*/
public class MySharePref {
private static final String SETTINGS = "com.blogspot.hu2di.settings";
private static final String KEY_NEWS = "news";
public static boolean getIsNews(Context context) {
SharedPreferences preferences = context.getSharedPreferences(SETTINGS, Context.MODE_PRIVATE);
return preferences.getBoolean(KEY_NEWS, true);
}
public static boolean putIsNews(Context context, Boolean value) {
SharedPreferences preferences = context.getSharedPreferences(SETTINGS, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean(KEY_NEWS, value);
return editor.commit();
}
}