SharePreferences使用

获取数据:

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

  

posted @ 2015-09-30 11:41  jasonkent27  阅读(173)  评论(0编辑  收藏  举报