zoukankan      html  css  js  c++  java
  • 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);
    	}
    

      

  • 相关阅读:
    Go 映射 (map)
    Go 字节 (byte) & 文字符号 (rune)
    Go 数组(array) & 切片(slice)
    Go 字符串 (string)
    Go 变量(var) & 常量(const)
    Go 循环 (for)
    Go 函数
    Go package: strings
    Linux crontab (定时任务)
    Python gc
  • 原文地址:https://www.cnblogs.com/jasonkent27/p/4848774.html
Copyright © 2011-2022 走看看