sharedpreferences

image view Shared preferences

吃可爱长大的小学妹 提交于 2019-12-13 10:52:15
问题 I'm newbie in android. My question is how to set shared preferences in image view. I want to shared the image to another activity. Please help me because I'm stocked on it.. Please help me the explain me clearly and codes. Thank you. 回答1: The "standard" way to share data across Activities is usign the putExtraXXX methods on the intent class. You can put the image path in your intent: Intent intent = new Intent(this,MyClassA.class); intent.putExtra(MyClassA.IMAGE_EXTRA, imagePath);

SharedPreferences in non activity class NullPointerException [duplicate]

时光总嘲笑我的痴心妄想 提交于 2019-12-13 10:22:24
问题 This question already has answers here : What is a NullPointerException, and how do I fix it? (12 answers) Closed last year . I'm trying to use SharedPreferences in a non activity class from onResume() in an activity but I'm getting a NullPointerException on the context . For some reason I cannot get the context in onResume() . Not sure if I'm missing something, but any help would be appreciated. onResume() Method in my activity @Override protected void onResume() { super.onResume(); // The

Unable to save ArrayList value in Shared Preference in Andorid

岁酱吖の 提交于 2019-12-13 10:17:06
问题 Can any one help me whats wrong in my code unable to save ArrayList document value in shared Preference getting null value in Debug of Array List Document please help me Thanks in advance here is my JSON response { "errCode": 0, "message": "Success", "responseDestinationDocument": [ { "name": "United Arab Emirates", "document": [ { "name": "Passport Front", "id": "2", "notes": [ { "name": "Upload colored passport copies." }, { "name": "Passport should be valid 6 months from the date of entry

How to use shared preference to send data from activity to fragment?

女生的网名这么多〃 提交于 2019-12-13 10:09:43
问题 I'm trying to send integer value from activity to a fragment to change text size value, Iv tried user bundle and custom constructor and didn't work. So how can I use shared preferences for this purpose? 回答1: If you insist on shared preference use this code : To save the data private void saveSp(String key , String value){ PreferenceManager.getDefaultSharedPreferences(Context) .edit() .putString(key, value).apply(); } To get your data: PreferenceManager.getDefaultSharedPreferences(Context)

In android, How do i save response coming from php login script as shared preference?

我的梦境 提交于 2019-12-13 09:58:42
问题 i have seen most of the examples of offline apps , but what should i do if my response comes from php api ? Basically my app logins and give request to an api , and i get a response. Suppose i get reponse as email and a token. So how should i use it in session management? so that user don't have to login all the time when he exits app. 回答1: you can store email and token in shared prefrence like this when user succefully login store data in sharedpreferences like this public static final

Choose only Selected JSON Value and save in sharedPreferences?

浪尽此生 提交于 2019-12-13 09:29:30
问题 I am Able to Parse JSON Data.Exactly what is the issue is that ,i want to store the Student ID in the SharedPreference without suffix i.e means only the integer is to be stored? I have tried to split the JSON Value with REGEX but not able,since i have not used regex.How can this issue be solved?? { "StdID":S001, "NAME":"Kirsten Green", "PHONENO":"095-517-0049", "DOB":"2009-12-28T00:00:00", "CLASS":9, "GENDER":"M", "ADDRESS":"8254 At Ave", "NATIONALITY":"Belgium", "ENROLLEDYEAR":"2016-04-21T00

how to append data in Shared Preference in Android

醉酒当歌 提交于 2019-12-13 09:23:27
问题 I tried to append the data in shared preference file by using SharedPreferences sharedPreferences = getSharedPreferences("myData", MODE_APPEND); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString("name", userName.getText().toString()); editor.putString("password", password.getText().toString()); editor.commit(); But I found that new value overwrites the old value. Will you help me to fix this issue? 回答1: MODE_APPEND doesn't mean that you add multiple values for each

RuntimeException when trying to store value fetched from server to sharedpreferences using Asynctask

跟風遠走 提交于 2019-12-13 08:45:33
问题 i am using sharedpreferences to check the app is using for the first time or not.if the app is using for first time registration screen will show , and after that MainActivity will show if registration is completed succussfully or used later . Registration screen is showing when app is runnig for first time but the issue is there in Registering. while calling the shared preferences from MainActivity to insert value in it. and the issue is RuntimeException .this is what i am doing for that...

How to store array values of type String[] and BigInteger[] into shared preference inside for loop

坚强是说给别人听的谎言 提交于 2019-12-13 06:51:29
问题 I am receiving the following array values in a for loop: String[] array1 = new String[""]; BigInteger array2 = new BigInteger[10]; for (int i = 0; i <= count; i++) { array1[i] //of type string array array2[i] //of type bigint array //Now inside same loop i want to store and retrieve those values of array from shared preferences. Can someone tell me how to store values of array into preference which are of type String[] and BigInteger[] } 回答1: If you want to store whole array data in shared

What's the best way to skip an Activity [duplicate]

梦想与她 提交于 2019-12-13 06:21:04
问题 This question already has answers here : Having trouble skipping an activity (2 answers) Closed 5 years ago . I'm developing an app in which a user logs in to his dashboard and stays logged in until he logs out (I mean if the app is closed and restarted, he still stays logged in). I'm using SharedPreferences to check if the user is actually logged in. Preference.java public class Preference { Context context; SharedPreferences sharedPref; public Preference(Context context){ this.context =