I am developing an android application in which i have several buttons with some text in them. I used these buttons as tags so that when the application installed these 50 buttons will show on screen as tags. Now what i want is that if a user does not want these tags then they can remove the button permanently. i.e. if their is a tag named "Free Delivery" and user doesnot want this then the user can click on the button and if choose Yes then the button of Free Delivery will be deleted permanently and it will not appear next time when user opens the application. How to do this? I have tried this:
button1.setVisibilty(View.GONE);
but when the user open the app next time then the button again showed up Please HELP!
You can save the preferences of the user with SharedPreferences
, it's a way to save information whithout connexion to a database.
Here is the Google's documentation for the SharedPreferences.
You can find how to use them in a already resolved question here
An example of how save a preference :
SharedPreferences preferences =
PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = preferences.edit();
editor.putString("Name","Alan");
editor.apply();
And here how to get it :
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
String name = preferences.getString("Name", null);