sharedpreferences

SharedPreferences Value Continues to Return as Zero - Cannot Retrieve Value of 'Data' String

旧时模样 提交于 2019-12-13 02:29:53
问题 I'm attempting to pull the byteswapped MDN value from SharedPreferences but it continues to return the value of zero - when it should return the byteswapped MDN instead. I'm saving it using the following format: editor.putString(new String("data"), Integer.toString(0)); and getting it using the following format: String info = String.format("USI%sCN%s,WN%s", tag + status + tag + settings.getString("data", Integer.toString(0)) + tag + DToDevice + tag, mobileStr, totalStr + settings.getString(

Sharedpreferences in Android returns null when called from another activity

时间秒杀一切 提交于 2019-12-13 01:43:14
问题 I made two activities, one for the widget and one for the settings activity. There are two variables "strSavedMem1" & "strSavedMem1" initialised in the settings activity... and are made via sharedPreference method. But when I try to use the variable in widget activity, the variable return a "null" value. The widget Activity: package com.eightbitcloud.example.widget; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Calendar; import

How do I retrieve the previous fragment upon opening an app from background? (app that wasn't killed)

邮差的信 提交于 2019-12-13 01:42:53
问题 I have a pretty unique issue where I am trying to retrieve previous fragment that was there before I went to the homescreen via the current fragment( last visible fragment) Not to confuse any further, here's the steps to repro my issue 1 ) launch the mainactivity, from there open fragment A via a button click (say button A) 2) from fragment A , press another button ,say B, which will open fragment B. 3) Fragment B has a close and save button , pressing which leads me back to the previous

Public shared preferences causes app to crash

假如想象 提交于 2019-12-13 01:25:49
问题 I need to have a shared preference that can be accessed by multiple methods in my class. To do this I set the shared preference public like this: public SharedPreferences myPreference = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); Then I can access it like this from two different methods: SharedPreferences.Editor editor=myPreference.edit(); when I do this the app crashes, here is the logcat: 01-23 18:02:51.764 20873-20873/com.example.griffin.dinnerplannerapp E

Dynamically created buttons have same label after restarting application?

。_饼干妹妹 提交于 2019-12-13 00:36:57
问题 I'm using a predefined button to generate new buttons when click on it. After generating new buttons I wish to change their label for that I'm using EditText defined in dialog box which pops up onLongClick of new generated buttons. To store all the generated buttons and their label I'm using Shared preferences . But the problem is after restarting all the generated buttons have same label on them. code in mainactivity----- SharedPreferences prefs=null; String key; int btncount = 15; code in

Save CheckBox State to SharedPreferences File in Android

孤街醉人 提交于 2019-12-12 23:50:27
问题 I have a couple of check boxes that I need to save so that when the user opens the Application again, they can see the state that they left the application in. I have tried using the preferences but I can't seem to get the result correctly. MainActivity.java package com.example.android.documentchecklist; import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android

Can't access SharedPreferences from my Service

心已入冬 提交于 2019-12-12 23:40:07
问题 What I'm trying to do Hello Guys. I got a Service which, set's a boolean to true or to false whenever the service is started or stopped (started = true / stopped = false) in the SharedPreference. Now when I try to get the Boolean out there in my Activity, it allways dosn't find it. How can I solve this... Here's the Code for you Guys. Code Methode in my Service: private void setStarted(boolean started) { // SharedPreferences casten mPrefs = this.getSharedPreferences(LOG_TAG, MODE_PRIVATE); //

how to store a value in Phonegap apps, any way other than database

这一生的挚爱 提交于 2019-12-12 23:09:47
问题 hi friends i am a mobile developer. So far i have worked in iPhone apps and android apps. Now i am working in Phone gap based apps for iPhone and Android mobiles. Now my problem is in my app i have a log in page where i have to enter the username and password and i return i use to get a unique is and token which i have to use for the whole app. If the app gets closed and opened after a long time i want this to be remained same. For this in ios apps we use a method called UserDefault method

Disable Dialog Notification in Shared Preference in android

时间秒杀一切 提交于 2019-12-12 21:00:38
问题 i have Shared preference in my application that has Ringtone .. i wanna to put Disable Notification SMS and MMS and notification from the app like alarm notification <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <CheckBoxPreference android:title="Disable Notification" android:defaultValue="true" android:key="checkbox" android:summary="Check the Box"/> </PreferenceScreen> This is one of my dialog notification code: //Alert

Trouble with SharedPreferences conflicting during app operation and then disappearing entirely after an app force close/reboot of device

只愿长相守 提交于 2019-12-12 20:25:54
问题 As the title suggest my problem is that some SharedPreferences I'm using are conflicting while the app operates, for example they seem to just be over writing each overs values, and not using their 'key'. Additionally once the application closes fully, force close/reboot, the file is lost completely. Logcat shows these possible hints, but I can't for the life of me get anything to work: 07-22 13:28:13.980: W/SharedPreferencesImpl(7905):org.xmlpull.v1.XmlPullParserException: Map value without