您的位置:首页 > Web前端

SharePreferences使用

2015-09-30 11:41 260 查看
获取数据:

@SuppressLint("InlinedApi")
private String getFromSharePreference(String key) {
if (TextUtils.isEmpty(key)) {
return null;
}
if (mShare == null) {
if (VERSION.SDK_INT >= 11) {
mShare = this.getSharedPreferences(
SHAREPREFERENCES_SCAN_COURSE,
Context.MODE_MULTI_PROCESS);
} else {
mShare = this.getSharedPreferences(
SHAREPREFERENCES_SCAN_COURSE, Context.MODE_PRIVATE);
}
}
return mShare.getString(key, null);
}


  插入数据:

@SuppressLint("InlinedApi")
private String getFromSharePreference(String key) {
if (TextUtils.isEmpty(key)) {
return null;
}
if (mShare == null) {
if (VERSION.SDK_INT >= 11) {
mShare = this.getSharedPreferences(
SHAREPREFERENCES_SCAN_COURSE,
Context.MODE_MULTI_PROCESS);
} else {
mShare = this.getSharedPreferences(
SHAREPREFERENCES_SCAN_COURSE, Context.MODE_PRIVATE);
}
}
return mShare.getString(key, null);
}


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: