-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
242 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
app/src/main/java/com/dudaizhong/news/base/utils/SharedPreferencesUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.dudaizhong.news.base.utils; | ||
|
||
import android.content.Context; | ||
import android.content.SharedPreferences; | ||
|
||
import com.dudaizhong.news.app.Constants; | ||
|
||
/** | ||
* Created by Dudaizhong on 2016/10/15. | ||
*/ | ||
|
||
public class SharedPreferencesUtil { | ||
|
||
|
||
private final static String USER_INFO = "user_info"; | ||
private final static String FIRST = "first"; | ||
|
||
private static Context context; | ||
|
||
public static void init(Context context) { | ||
SharedPreferencesUtil.context = context; | ||
} | ||
|
||
public static void setVersion(String version) { | ||
SharedPreferences.Editor editor = context.getSharedPreferences(USER_INFO, Context.MODE_PRIVATE).edit(); | ||
editor.putString(Constants.VERSION, version); | ||
editor.apply(); | ||
} | ||
|
||
public static String getVersion() { | ||
SharedPreferences preferences = context.getSharedPreferences(USER_INFO, Context.MODE_PRIVATE); | ||
return preferences.getString(Constants.VERSION, ""); | ||
} | ||
|
||
/** | ||
* 检查是否加载引导页 | ||
* @param first | ||
*/ | ||
public static void setFirst(boolean first) { | ||
SharedPreferences.Editor editor = context.getSharedPreferences(FIRST, Context.MODE_PRIVATE).edit(); | ||
editor.putBoolean(Constants.FIRST, first); | ||
editor.apply(); | ||
} | ||
|
||
public static Boolean getFirst() { | ||
SharedPreferences preferences = context.getSharedPreferences(FIRST, Context.MODE_PRIVATE); | ||
return preferences.getBoolean(Constants.FIRST, false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.