Saving Data on Android



Download 19,28 Mb.
Pdf ko'rish
bet43/292
Sana24.01.2022
Hajmi19,28 Mb.
#407089
1   ...   39   40   41   42   43   44   45   46   ...   292
Bog'liq
Bailey J., Dominguez A., Djermanovic D. - Saving Data on Android (1st Edition) - 2019

SharedPreferences
, or 
prefs
 for short, API provides the means to read and 
write to a file that is formatted as 
XML
. The API is especially useful when you need 
to store things like application-wide flags to style your app, user progress, data 
filters and so on.
The prefs file you create, edit and can delete is stored in the 
data/data/{application 
package name}
 directory. The location of this file can be obtained programmatically 
by calling 
Environment.getDataDirectory()
. Like files, the data is app—specific 
and will be lost if the application data is cleared through settings or if the app is 
uninstalled.
You already learned that 
SharedPreferences
 should not be used to store large 
amounts of data, but rather small features of your app. As such, the data is 
structured into 
key—value
 pairs, where each value has an identifier key, which 
marks its location in the file. Then, by passing in the key, you can retrieve the last 
value you stored. If there is no value for the key, you can specify a default that will be 
returned instead. Furthermore, since the point of 
SharedPreferences
 is to store 
simple data, the only supported types to store are 
Int

Float

Long

String
 and 
Set
.
raywenderlich.com
41



Download 19,28 Mb.

Do'stlaringiz bilan baham:
1   ...   39   40   41   42   43   44   45   46   ...   292




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish