首页 > 其他 > 详细

SharePreferences使用

时间:2015-09-30 13:01:14      阅读:224      评论:0      收藏:0      [点我收藏+]

获取数据:

	@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);
	}

  

SharePreferences使用

原文:http://www.cnblogs.com/jasonkent27/p/4848774.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!