android-sharedpreferences

SharedPreferences in Android app for remember me button

北城以北 提交于 2019-12-11 16:11:53
问题 Im not to sure what I'm doing wrong. In my app I'm trying to have it remember a previous password entered into the textfield on submit. From research done using shared preferences saving the variable even if the app it restarted. Top of my code: public class AK_Voucher_access extends BT_fragment{ View thisScreensView = null; String errormessage = ""; String errormessageTextColor = ""; String errormessageText = ""; String rememberTextText = ""; String rememberTextTextColor = ""; String

What does “clear data” in application settings do?

穿精又带淫゛_ 提交于 2019-12-11 08:41:23
问题 I have added below a screenshot I took of the app settings page. I want to know what the clear data and the force stop will do to my app? Specifically, if my app has stored data into a file (I'm making a game and I want to store the progress) and the user presses any one of those buttons, especially clear data , I want to know if my file will be deleted and all the progress of the user in the game will be lost. If I have stored my files in internal storage, will this happen? If so, should I

Error trying to use GSON with own class

霸气de小男生 提交于 2019-12-11 05:42:06
问题 I'm trying to use Google's GSON for the first time in my Android app. I want to use GSON with a class called UserValues , which keeps most of my ArrayList, booleans, Strings and other basic objects in one place. My goal is to save an instance of UserValues into SharedPreferences . I wrote: Gson gson = new Gson(); String userValuesJSON=gson.toJson(userValues); getSharedPreferences(myAppKey, MODE_PRIVATE).edit().putString("JSON", userValuesJSON).commit(); The error I get: java.lang

Shared preferences in Android doesn't save when i switch activity or close app

家住魔仙堡 提交于 2019-12-10 12:27:12
问题 I checked similar questionsions and noting seems to work. I can't figure out what seems to be the problem. Value goes to 0 after every app restart or activity switch. //just parts of code from activity1 SharedPreferences pref; SharedPreferences.Editor editor; // On create.... pref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); editor = pref.edit(); max=pref.getInt("mxtime", 0); //If something>something... editor.putInt("mxtime", max); editor.commit(); In the first

Save user input to SharedPrefernces and set Value to EdiText

让人想犯罪 __ 提交于 2019-12-10 11:44:39
问题 I want to save user input to SharedPreferences when i click a button so that when a user launches the activity again the user input is set to the EditText and TextView. I already have a sharedPreferences File created that i save some text to in a previous activity. I want update the SharedPreferences File with another details from this new activity that i created. This is code for creating and saving to SharedPreferences private SharedPreferences prefs; public static final String PREF_FILE

Save user input to SharedPrefernces and set Value to EdiText

北战南征 提交于 2019-12-08 14:06:27
I want to save user input to SharedPreferences when i click a button so that when a user launches the activity again the user input is set to the EditText and TextView. I already have a sharedPreferences File created that i save some text to in a previous activity. I want update the SharedPreferences File with another details from this new activity that i created. This is code for creating and saving to SharedPreferences private SharedPreferences prefs; public static final String PREF_FILE_NAME = "AuthUser"; prefs = this.getSharedPreferences(PREF_FILE_NAME, Context.MODE_PRIVATE); txtDate =

How do I get SharedPreference object in FragmentStatePagerAdapter?

这一生的挚爱 提交于 2019-12-08 13:15:03
问题 I wanna add an integer dynamically in the getCount() method of custom pager adapter that obviously extends FragmentStatePagerAdapter. return some integer value; I have a counter saved in Shared Preference object and it gets updated with clicks on star images. I wanna return the updated counter value in the mentioned method, so I can generate that many swipe views but the problem is I unable to get Shared Preference object there. This is the only obstacle between my app and the play store, I

LiveData with shared preferences

左心房为你撑大大i 提交于 2019-12-05 16:55:16
问题 I have a settings screen where I am setting some values. When I set those values it gets saved in shared preferences and these values are needed in my request to the network api call as parameters. Now I can use a listener for shared preferences in my activity then make an api call and get fresh data, but I want to use this with LiveData. How can I listen for changes in the shared preferences using LiveData and then make the network call using the new parameters. 回答1: Java Code by Idish,

How do I restart this wallpaper engine after settings have been updated?

南楼画角 提交于 2019-12-04 13:59:14
问题 I'm creating a live wallpaper and I'm using this tutorial as a starting point: http://code.tutsplus.com/tutorials/create-a-live-wallpaper-on-android-using-an-animated-gif--cms-23088 I'm trying to add a settings menu to let the user choose one of four backgrounds. I have everything working using SharedPreferences . The only problem is that the wallpaper does not update after the setting is changed in the settings menu. If you restart the app, the background will be updated with the last

How to examine SharedPreferences from adb shell?

断了今生、忘了曾经 提交于 2019-12-03 01:52:34
问题 Now that we can Examining sqlite3 Databases from a Remote Shell, is it possible to examine SharedPreferences from adb shell? Since it would be much more convenient to examine and manipulate SharedPreferences from command line when debugging. Or put in another way, in what files SharedPreferences are saved, and how to view and modify these files? 回答1: Fine, I found the file just after I raised the question above. (It seem asking questions publicly stimulate me to search answers by myself much