parent
fb534c9e36
commit
4708b66ab6
@ -1,38 +0,0 @@
|
|||||||
package net.micode.notes.util;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
|
|
||||||
public class SpfUtil {
|
|
||||||
|
|
||||||
private static String SPF_NAME = "noteSpf";
|
|
||||||
|
|
||||||
public static void saveString(Context context, String key, String value) {
|
|
||||||
SharedPreferences spf = context.getSharedPreferences(SPF_NAME, Context.MODE_PRIVATE);
|
|
||||||
SharedPreferences.Editor edit = spf.edit();
|
|
||||||
edit.putString(key, value);
|
|
||||||
edit.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getString(Context context, String key) {
|
|
||||||
SharedPreferences spf = context.getSharedPreferences(SPF_NAME, Context.MODE_PRIVATE);
|
|
||||||
return spf.getString(key, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void saveInt(Context context, String key, int value) {
|
|
||||||
SharedPreferences spf = context.getSharedPreferences(SPF_NAME, Context.MODE_PRIVATE);
|
|
||||||
SharedPreferences.Editor edit = spf.edit();
|
|
||||||
edit.putInt(key, value);
|
|
||||||
edit.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getInt(Context context, String key) {
|
|
||||||
SharedPreferences spf = context.getSharedPreferences(SPF_NAME, Context.MODE_PRIVATE);
|
|
||||||
return spf.getInt(key, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getIntWithDefault(Context context, String key, int defValue) {
|
|
||||||
SharedPreferences spf = context.getSharedPreferences(SPF_NAME, Context.MODE_PRIVATE);
|
|
||||||
return spf.getInt(key, defValue);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
package net.micode.notes.util;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
public class ToastUtil {
|
|
||||||
|
|
||||||
public static void toastShort(Context context, String msg) {
|
|
||||||
Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void toastLong(Context context, String msg) {
|
|
||||||
Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in new issue