I have buttons in an activity.On clicking any button an alert dialog opens up with the check boxes .The user clicks on any checkbox and the value is stored in array list.Now I want to receive the check boxes value in another activity and print the value of the checked values saying these are the checked values.How can you do the same?
Asked
Active
Viewed 49 times
-2
-
1You can start the new activity when the dialog is dismissed and pass the array list in intent. This use-case you can implement or else you can take the help of an interface to get the values in the activity. – Jaymin Jan 31 '20 at 06:10
-
https://stackoverflow.com/q/21250339/5705721 – Makarand Jan 31 '20 at 06:11
1 Answers
0
You can just save your array list in shared preference and then show it on another activity
Save ArrayList in SharedPrefrence
Gson gson = new Gson();
String value= gson.toJson(list);
editor.putString(key, value);
Retrive ArrayList on Second Activity
Gson gson = new Gson();
String value= prefs.getString(key, null);
Type type = new TypeToken<ArrayList<String>>() {}.getType();
ArrayList<String> showDataList= gson.fromJson(json, type);
For more information look at this Save ArrayList to SharedPreferences

S.Ambika
- 292
- 1
- 14