/shared_prefs目錄下。SharedPreferences對(duì)象本身只能獲取數(shù)據(jù)而不支持存儲(chǔ)和修改,存儲(chǔ)修改是通過(guò)Editor對(duì)象實(shí)現(xiàn)。。。' />

日韩视频中文字幕_最新中文字幕在线_天天精品_欧美一级在线_亚洲男人天堂网_麻豆乱码国产一区二区三区

1、SharedPreferences的簡(jiǎn)單介紹

        應(yīng)用程序在運(yùn)行的時(shí)候,可能會(huì)隨著用戶的使用而保持該用戶的配置信息,如上次播放時(shí)的eq設(shè)置,音量設(shè)置,上網(wǎng)的cookies信息等等,這些小量 的信息可以通過(guò)SharedPreferences來(lái)保持,通過(guò)SharedPreferences保持的數(shù)據(jù)為一個(gè)XML文件,位于應(yīng)用程序的私有文件夾。

2、具體操作方法

獲取SharedPreferences,可以通過(guò)以下方法獲取

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.

 

參數(shù)簡(jiǎn)述:

Name————獲得SharedPreferences之后,將會(huì)在應(yīng)用程序的私有文件夾中保存著一個(gè)XML文件,第一個(gè)參數(shù)name就是這個(gè)文件名字。

Mode————XML文件的保存模式,默認(rèn)為0,也就是MODE_PRIVATE

 

3、簡(jiǎn)單的demo

通過(guò)service的一個(gè)音樂(lè)播放例子,“播放”與“暫停”兩個(gè)按鈕

暫停之后,保持播放進(jìn)度到SharedPreferences里面,然后再次播放的話,讀取進(jìn)度值進(jìn)行音樂(lè)播放。

穩(wěn)定

產(chǎn)品高可用性高并發(fā)

貼心

項(xiàng)目群及時(shí)溝通

專業(yè)

產(chǎn)品經(jīng)理1v1支持

快速

MVP模式小步快跑

承諾

我們選擇聲譽(yù)

堅(jiān)持

10年專注高端品質(zhì)開發(fā)
  • 返回頂部
主站蜘蛛池模板: 狠狠爱www人成狠狠爱综合网 | 国产极品美女在线精品图片 | 欧美 日韩 中文字幕 | 国产一区二区三区在线看 | 国产欧美日韩 | 影音先锋在线看片资源 | 欧美日韩精品一区二区三区 | 精品久久一区二区三区 | www.huangse | 日韩视频精品 | 精品久久久久久久 | 在线视频偷国产精品 | 国产专区在线播放 | 欧美日韩精品一区二区 | 国产一区二区三区av在线 | www国产亚洲精品久久网站 | 免费观看视频www | 亚洲日本韩国在线观看 | 男人操女人bb| 欧美一级免费看 | 亚洲精品在线网站 | 欧美日韩精品在线观看 | 99视频网| 久久国产一区二区 | 狠狠色伊人亚洲综合成人 | 成人久久18免费观看 | 日本不卡一区二区 | 亚洲免费小视频 | 国产精品久久久久久久久久东京 | 久久99精品国产麻豆不卡 | 中文字幕乱码一区二区三区 | 国产精品视频一区二区三区 | av一区二区三区四区 | 成人国产在线观看 | 久久综合久久久 | 涩涩久久 | 亚洲九九九 | 亚洲国产精品99久久久久久久久 | 91色在线观看 | 18韩国主播福利视频在线观看 | 在线不卡一区 |