/shared_prefs目錄下。SharedPreferences對象本身只能獲取數據而不支持存儲和修改,存儲修改是通過Editor對象實現。。。' />
  • <kbd id="qyk40"></kbd>
  • <strike id="qyk40"></strike><samp id="qyk40"><pre id="qyk40"></pre></samp>

    1、SharedPreferences的簡單介紹

            應用程序在運行的時候,可能會隨著用戶的使用而保持該用戶的配置信息,如上次播放時的eq設置,音量設置,上網的cookies信息等等,這些小量 的信息可以通過SharedPreferences來保持,通過SharedPreferences保持的數據為一個XML文件,位于應用程序的私有文件夾。

    2、具體操作方法

    獲取SharedPreferences,可以通過以下方法獲取

    public SharedPreferences getSharedPreferences (String name, int mode)

    Since: API Level 1

    Retrieve and hold the contents of the preferences file 'name', returning a SharedPreferences through which you can retrieve and modify its values. Only one instance of the SharedPreferences object is returned to any callers for the same name, meaning they will see each other's edits as soon as they are made.

    Parameters
    name Desired preferences file. If a preferences file by this name does not exist, it will be created when you retrieve an editor (SharedPreferences.edit()) and then commit changes (Editor.commit()).
    mode Operating mode. Use 0 or MODE_PRIVATE for the default operation,MODE_WORLD_READABLE andMODE_WORLD_WRITEABLE to control permissions. The bitMODE_MULTI_PROCESS can also be used if multiple processes are mutating the same SharedPreferences file.MODE_MULTI_PROCESS is always on in apps targetting Gingerbread (Android 2.3) and below, and off by default in later versions.
    Returns
    • Returns the single SharedPreferences instance that can be used to retrieve and modify the preference values.

     

    參數簡述:

    Name————獲得SharedPreferences之后,將會在應用程序的私有文件夾中保存著一個XML文件,第一個參數name就是這個文件名字。

    Mode————XML文件的保存模式,默認為0,也就是MODE_PRIVATE

     

    3、簡單的demo

    通過service的一個音樂播放例子,“播放”與“暫停”兩個按鈕

    暫停之后,保持播放進度到SharedPreferences里面,然后再次播放的話,讀取進度值進行音樂播放。

    穩定

    產品高可用性高并發

    貼心

    項目群及時溝通

    專業

    產品經理1v1支持

    快速

    MVP模式小步快跑

    承諾

    我們選擇聲譽

    堅持

    10年專注高端品質開發
    • 返回頂部
    久久久无码精品亚洲日韩蜜臀浪潮 | 亚洲性色精品一区二区在线| 亚洲∧v久久久无码精品| 中文字幕精品视频在线观| 午夜成人精品福利网站在线观看| 日韩人妻无码一区二区三区| 成人无码精品一区二区三区| 久久亚洲精品国产精品婷婷| 精品国产福利一区二区| 亚洲精品无码久久久久久久 | 亚洲日韩精品一区二区三区| 国产精品自在线拍国产电影| 国产成人久久精品麻豆一区| 第一福利永久视频精品| 精品人妻无码专区在中文字幕| 亚洲日韩精品一区二区三区无码| 国产精品久久久久久影视| 日韩精品中文字幕无码专区 | 久久精品中文字幕有码| 国产A∨免费精品视频| 国产高清在线精品一本大道国产 | 国产精品三级在线| 精品伊人久久大线蕉色首页| 揄拍自拍日韩精品| 亚洲伊人精品综合在合线| 亚洲国产成人精品电影| 精品女同一区二区三区免费站| 久久精品国产亚洲av麻豆图片| 精品免费久久久久久久| 精品无码久久久久国产动漫3d| 久久精品国产99国产精品导航| 国产成人精品男人的天堂538| 国产精品视频网站| 国产精品久线观看视频| 欧美黑人欧美精品刺激| 国产精品嫩草久久久久| 国产精品视频无圣光一区| 国产精品国产高清国产av | 久久精品加勒比中文字幕| 免费精品99久久国产综合精品 | 97久久国产亚洲精品超碰热|