AccountManager.java
1.35 KB
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.lotus.town.account;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
public class AccountManager {
private static AccountManager INSTANCE;
private static final String ACCOUNT_PREFERENCES = "account";
private static final String PREFERENCE_DEVICE_ID = "device_id";
private SharedPreferences mSharedPreferences;
private AccountManager(Context context) {
mSharedPreferences = context.getApplicationContext().getSharedPreferences(ACCOUNT_PREFERENCES, Context.MODE_PRIVATE);
}
public static AccountManager getInstance(Context context) {
if (INSTANCE == null) {
synchronized (AccountManager.class) {
if (INSTANCE == null) {
INSTANCE = new AccountManager(context);
}
}
}
return INSTANCE;
}
public boolean isNewerNoMark(){
boolean ret = mSharedPreferences.getString(PREFERENCE_DEVICE_ID, null) == null;
return ret;
}
public boolean isNewer() {
boolean ret = mSharedPreferences.getString(PREFERENCE_DEVICE_ID, null) == null;
if (ret) {
SharedPreferences.Editor editor = mSharedPreferences.edit();
editor.putString(PREFERENCE_DEVICE_ID, Build.SERIAL);
editor.apply();
}
return ret;
}
}