sharedpreferences

Method onDestroy() doesn't work

自闭症网瘾萝莉.ら 提交于 2020-01-26 04:33:04
问题 When I run my app, all the checkboxes are checked in my ListView but I don't want them checked at the start. I think I didn't write onDestroy() correctly. Please help me! Here is my code: Adapter: public abstract class PlanetAdapter extends ArrayAdapter<Planet> implements CompoundButton.OnCheckedChangeListener { private List<Planet> planetList = null; private Context context = null; ArrayList<Birra> objects; private HashMap<Integer, Planet> pizzaSelected = new HashMap<>(); public boolean

save the state of button in android

六眼飞鱼酱① 提交于 2020-01-26 01:14:44
问题 am working on camera application i have two imageview one is auto and second is pro i want when i click on auto auto is selected and image icon changes and when i click on pro automatically auto view deselected and pro view is selected autobtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { autobtn.setImageResource(R.drawable.autoactive); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(ModeActivity.this);

How to save spinner to saved/shared preferences

懵懂的女人 提交于 2020-01-25 12:12:20
问题 I am able to save Strings in my saved preferences but having difficulty saving my spinner. public class Diet extends Activity { private SharedPreferences sharedPreferences; Spinner spnCalorieRange; Here is my onCreate: sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); String strAge = Integer.toString(age); String strHeight = Integer.toString(height); String strWeight = Integer.toString(weight); name = loadSavedPreference("name"); strAge = loadSavedPreference("strAge");

How to save spinner to saved/shared preferences

两盒软妹~` 提交于 2020-01-25 12:09:08
问题 I am able to save Strings in my saved preferences but having difficulty saving my spinner. public class Diet extends Activity { private SharedPreferences sharedPreferences; Spinner spnCalorieRange; Here is my onCreate: sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); String strAge = Integer.toString(age); String strHeight = Integer.toString(height); String strWeight = Integer.toString(weight); name = loadSavedPreference("name"); strAge = loadSavedPreference("strAge");

How do I save user session using SharedPreferences in Cloud Firestore when I'm not using Firebase authentication?

守給你的承諾、 提交于 2020-01-25 10:21:13
问题 When a user registers in my Android app, their data is stored inside a collection, where the document ID is their email address which helps find a user. The password is stored inside the document as well. So when a user logins, their entered email is checked against a document ID matching that email, if it exists it will log in and display user control panel. Now after the login, I need to somehow create a user session, so that the user can never go back to the login screen until he logouts.

How to save activity state after pressing back button?

馋奶兔 提交于 2020-01-25 07:04:26
问题 I have 2 activities A and B first one having products list and second one is the shopping cart. On click of a button in the list I am adding products to the cart. Now I go to the cart and delete some items from it. I press back and came to the activity A again. Now if I go to the B(cart) again the list is null i.e there are no products in the cart. I am using onSaveInstanceState and onRestoreInstanceState to save an restore the instance of cart activity but that is not working. Perhaps this

How do I retrieve shared preferences data in a Widget Service class without passing in incorrect default values or getting null pointer errors?

我只是一个虾纸丫 提交于 2020-01-24 17:05:25
问题 I am trying to run a widget in my app. The widget data (sync frequency, username, etc) is decided in the WidgetConfig class. It then opens a widget provider, which creates the widget, and lastly a service updates the views and makes the server calls to update data. Here is some of my code: //First Widget config is called: public class WidgetConfig extends Activity{ //Stuff happens here to get data from EditTexts and spinners and converts //them to strings. //Eventually a button is pressed

How do I retrieve shared preferences data in a Widget Service class without passing in incorrect default values or getting null pointer errors?

心不动则不痛 提交于 2020-01-24 17:05:14
问题 I am trying to run a widget in my app. The widget data (sync frequency, username, etc) is decided in the WidgetConfig class. It then opens a widget provider, which creates the widget, and lastly a service updates the views and makes the server calls to update data. Here is some of my code: //First Widget config is called: public class WidgetConfig extends Activity{ //Stuff happens here to get data from EditTexts and spinners and converts //them to strings. //Eventually a button is pressed

Loading JSON data to android listpreference

和自甴很熟 提交于 2020-01-23 12:36:05
问题 I have a problem.I have read many forums and topics but I can not understand how to create a class file to load JSON data like: {"city":[{"id":"1","name":"London"},{"id":"2","name":"Berlin"},{"id":"3","name":"New York"}],"success":1} to an ListPreference list for saving one value to shared preference file. Like my saved url: <string name="URL">192.168.1.100/data</string> without deprecated methods ( findPreference("city") ). The preference xml which I use is <?xml version="1.0" encoding="utf

Handling multiple instances of appwidget

风流意气都作罢 提交于 2020-01-22 10:29:34
问题 I have a configuration activity, a large widget provider and a small widget provider. From configuration activity i save some values in shared preferences. From large and small app widget providers i get those shared preferences. I am not able to give the app widget unique ids and i want to have different shared preferences each time i move on from configuration activity to app widget provider. How can i achieve this. 回答1: To give unique widget ids for each instances of the app widget, you