修改动态和部分我的界面

This commit is contained in:
被淹死的鱼
2026-03-17 20:24:06 +08:00
parent 48f01f0942
commit b03b04dad5
1166 changed files with 10063 additions and 6325 deletions

View File

@@ -0,0 +1,83 @@
package com.xuebiping.bolizhuzi.utils;
import android.content.Context;
import android.content.SharedPreferences;
/**
* Created by zhangbin on 2019/1/10.
*/
public class CitySPUtils {
private final static String name = "city_config";
private final static int mode = Context.MODE_PRIVATE;
/**
* 保存首选项
* @param context
* @param key
* @param value
*/
public static void saveBoolean(Context context, String key, boolean value){
SharedPreferences sp = context.getSharedPreferences(name, mode);
SharedPreferences.Editor edit = sp.edit();
edit.putBoolean(key, value);
edit.commit();
}
public static void saveInt(Context context, String key, int value){
SharedPreferences sp = context.getSharedPreferences(name, mode);
SharedPreferences.Editor edit = sp.edit();
edit.putInt(key, value);
edit.commit();
}
public static void saveString(Context context, String key, String value){
SharedPreferences sp = context.getSharedPreferences(name, mode);
SharedPreferences.Editor edit = sp.edit();
edit.putString(key, value);
edit.commit();
}
/**
* 获取首选项
* @param context
* @param key
* @param defValue
* @return
*/
public static boolean getBoolean(Context context, String key, boolean defValue){
SharedPreferences sp = context.getSharedPreferences(name, mode);
return sp.getBoolean(key, defValue);
}
public static int getInt(Context context, String key, int defValue){
SharedPreferences sp = context.getSharedPreferences(name, mode);
return sp.getInt(key, defValue);
}
public static int getInt(Context context, String key){
SharedPreferences sp = context.getSharedPreferences(name, mode);
return sp.getInt(key, 0);
}
public static String getString(Context context, String key, String defValue){
SharedPreferences sp = context.getSharedPreferences(name, mode);
return sp.getString(key, defValue);
}
public static String getString(Context context, String key) {
SharedPreferences sp = context.getSharedPreferences(name, mode);
return sp.getString(key, "");
}
/**
* 清除保存
* @param context
*/
public static void clear(Context context){
SharedPreferences sp = context.getSharedPreferences(name, mode);
SharedPreferences.Editor editor = sp.edit();
editor.clear();
editor.commit();
}
}