Android设置|(文件)配置(Android Setting|( file ) Configuration)
我有以下方法来保存应用程序设置中的连接字符串,是否有任何Android文件(asp.net中的web配置)处理用户可以“读写”的信息?
public static System.String StrConnectionstring { get { if (DB._StrConnectionstring == null) { return AppSettings.GetConnectionSettings("DSN"); } return DB._StrConnectionstring; } set { DB._StrConnectionstring = value; } }i have the following method to save connection string in app setting , is there is any android file like (web config in asp.net) which handle the information from which user can "read write"?
public static System.String StrConnectionstring { get { if (DB._StrConnectionstring == null) { return AppSettings.GetConnectionSettings("DSN"); } return DB._StrConnectionstring; } set { DB._StrConnectionstring = value; } }最满意答案
使用共享首选项:
宣言 :
public static final String MYPREFS = "MySharedPreferenceFile"; SharedPreferences settings; SharedPreferences.Editor editor;初始化:
settings = context.getSharedPreferences(MYPREFS, 0); editor = settings.edit();存储值:
editor.putString("Name","test"); editor.commit();要检索值:
settings.getString("Name",""); // here value field is for to specify default value谢谢。
Use Shared Preferences :
Declaration :
public static final String MYPREFS = "MySharedPreferenceFile"; SharedPreferences settings; SharedPreferences.Editor editor;Initialization :
settings = context.getSharedPreferences(MYPREFS, 0); editor = settings.edit();To store values :
editor.putString("Name","test"); editor.commit();To retrieve values :
settings.getString("Name",""); // here value field is for to specify default valueThanks.
更多推荐
发布评论