获取数据:
@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); }
转载于:https://www.cnblogs.com/jasonkent27/p/4848774.html