-
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
3 changed files
with
83 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.hss01248.flipper; | ||
|
||
import android.content.Context; | ||
import android.content.SharedPreferences; | ||
|
||
/** | ||
* Created by huangshuisheng on 2017/12/13. | ||
*/ | ||
|
||
class FliSpUtil { | ||
|
||
|
||
|
||
private static Context context; | ||
|
||
public static void init(Context app) { | ||
context = app; | ||
} | ||
|
||
private static final String SP_FILE_NAME = "SpUtilAD"; | ||
|
||
|
||
public static void putLong(String key,long val){ | ||
getSP().edit().putLong(key,val) | ||
.apply(); | ||
} | ||
|
||
public static long getLong(String key, long defVal) { | ||
return getSP().getLong(key, defVal); | ||
} | ||
|
||
public static void putBoolean(String key, boolean val) { | ||
getSP().edit().putBoolean(key, val).apply(); | ||
} | ||
public static boolean putBooleanNow(String key, boolean val) { | ||
return getSP().edit().putBoolean(key, val).commit(); | ||
} | ||
|
||
public static boolean getBoolean(String key, boolean defVal) { | ||
return getSP().getBoolean(key, defVal); | ||
} | ||
|
||
public static void putInt(String key, int val) { | ||
getSP().edit().putInt(key, val).apply(); | ||
} | ||
|
||
public static boolean putIntNow(String key, int val) { | ||
return getSP().edit().putInt(key, val).commit(); | ||
} | ||
|
||
public static int getInt(String key, int defVal) { | ||
return getSP().getInt(key, defVal); | ||
} | ||
|
||
public static void putString(String key, String val) { | ||
getSP().edit().putString(key, val).apply(); | ||
} | ||
|
||
public static String getString(String key, String defVal) { | ||
return getSP().getString(key, defVal); | ||
} | ||
|
||
public static void putFloat(String key, float val) { | ||
getSP().edit().putFloat(key, val).apply(); | ||
} | ||
|
||
public static float getFloat(String key, float defVal) { | ||
return getSP().getFloat(key, defVal); | ||
} | ||
|
||
private static SharedPreferences getSP() { | ||
return context.getSharedPreferences(SP_FILE_NAME, Context.MODE_PRIVATE); | ||
} | ||
} |
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