NameIcons = new HashMap



Download 15,84 Kb.
Sana05.03.2023
Hajmi15,84 Kb.
#916694
Bog'liq
Документ (2)


.Map nameIcons = new HashMap();
nameIcons.put("Noel", "/location/to/noel/icon.png");
nameIcons.put("Bob", "another/location/to/bob/icon.png");
nameIcons.put("another name", "last/location/icon.png");


SharedPreferences keyValues = getContext().getSharedPreferences("name_icons_list", Context.MODE_PRIVATE);
SharedPreferences.Editor keyValuesEditor = keyValues.edit();


for (String s : nameIcons.keySet()) {
// use the name as the key, and the icon as the value
keyValuesEditor.putString(s, nameIcons.get(s));
}
keyValuesEditor.commit()
New


public static void setPrefs(String key, String value, Context context){
SharedPreferences sharedpreferences = context.getSharedPreferences(Consts.SP_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(key, value);
editor.apply();
}public static String getPrefs(String key, Context context){
SharedPreferences sharedpreferences = context.getSharedPreferences(Consts.SP_NAME, Context.MODE_PRIVATE);
return sharedpreferences.getString(key, "notfound");
}
public static void setArrayPrefs(String arrayName, ArrayList array, Context mContext) {
SharedPreferences prefs = mContext.getSharedPreferences("preferencename"_,_0);__SharedPreferences.Editor_editor_=_prefs.edit();__editor.putInt(arrayName_+"_size"'>"preferencename", 0);
SharedPreferences.Editor editor = prefs.edit();
editor.putInt(arrayName +"_size", array.size());
for(int i=0;i editor.putString(arrayName + "_" + i, array.get(i));
editor.apply();
}public static ArrayList getArrayPrefs(String arrayName, Context mContext) {
SharedPreferences prefs = mContext.getSharedPreferences("preferencename", 0);
int size = prefs.getInt(arrayName + "_size", 0);
ArrayList array = new ArrayList<>(size);
for(int i=0;i array.add(prefs.getString(arrayName + "_" + i, null));
return array;
}
String value;Preferences.setPrefs("value","info",MainActivity.this);
value = Preferences.getPrefs("value",SomeActivity.this)

ArrayList mOrderList = new ArrayList();Preferences.setArrayPrefs("OrderList",mOrderList,context);
mOrderList= Preferences.getArrayPrefs("OrderList",context);
// my list of names, icon locations
Map nameIcons = new HashMap();
nameIcons.put("Noel", "/location/to/noel/icon.png");
nameIcons.put("Bob", "another/location/to/bob/icon.png");
nameIcons.put("another name", "last/location/icon.png");

SharedPreferences keyValues = getContext().getSharedPreferences("name_icons_list", Context.MODE_PRIVATE);
SharedPreferences.Editor keyValuesEditor = keyValues.edit();

for (String s : nameIcons.keySet()) {
// use the name as the key, and the icon as the value
keyValuesEditor.putString(s, nameIcons.get(s));
}
keyValuesEditor.commit()
public boolean saveArray(String[] array, String arrayName, Context mContext) {
SharedPreferences prefs = mContext.getSharedPreferences("preferencename", 0);
SharedPreferences.Editor editor = prefs.edit();
editor.putInt(arrayName +"_size", array.length);
for(int i=0;i editor.putString(arrayName + "_" + i, array[i]);
return editor.commit();
}
public String[] loadArray(String arrayName, Context mContext) {
SharedPreferences prefs = mContext.getSharedPreferences("preferencename", 0);
int size = prefs.getInt(arrayName + "_size", 0);
String array[] = new String[size];
for(int i=0;i array[i] = prefs.getString(arrayName + "_" + i, null);
return array;
}

Download 15,84 Kb.

Do'stlaringiz bilan baham:




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