乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      Android讀取對應(yīng)的鍵值

       昵稱2009261 2014-04-25

      Android讀取對應(yīng)的鍵值

      • 標(biāo)簽:獲得鍵值 更新時(shí)間:2014-04-16
      • Android讀取對應(yīng)的鍵值代碼,可獲得當(dāng)前的SharedPreferences對象,獲取消息,將鍵值對寫入配置文件,編輯SharedPreferences對象,插入和提交數(shù)據(jù)等功能。

        01import android.app.Activity;
        02import android.content.SharedPreferences;
        03public class MySharedPreferences {
        04/**
        05 * 讀取對應(yīng)的鍵值
        06 * @param key
        07 * @return String
        08 */
        09    public static int readMessage(Activity acivity,String key, int value) {
        10        //獲得當(dāng)前的SharedPreferences對象
        11        SharedPreferences message = acivity.getPreferences(Activity.MODE_PRIVATE);
        12        //獲取消息
        13        int tmp = message.getInt(key, value);
        14        return tmp;
        15    }
        16    /**
        17     * 將鍵值對寫入配置文件
        18     * @param key
        19     * @param value
        20     */
        21    public static void writeMessage(Activity acivity,String key, int value) {
        22        //創(chuàng)建一個(gè)SharedPreferences對象
        23        SharedPreferences message = acivity.getPreferences(0);
        24        //編輯SharedPreferences對象
        25        SharedPreferences.Editor editor = message.edit();
        26        //插入一個(gè)數(shù)據(jù)
        27        editor.putInt(key, value);
        28        //提交數(shù)據(jù)
        29        editor.commit();
        30    }
        31    public static String readMessage(Activity acivity,String key, String value) {
        32        SharedPreferences message = acivity.getPreferences(Activity.MODE_PRIVATE);
        33        String text = message.getString(key, value);
        34        return text;
        35    }
        36    public static void writeMessage(Activity acivity,String key, String value) {
        37        SharedPreferences message = acivity.getPreferences(0);
        38        SharedPreferences.Editor editor = message.edit();
        39        editor.putString(key, value);
        40        editor.commit();
        41    }
        42}

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請遵守用戶 評(píng)論公約

        類似文章 更多