How can i save the info from a multiple choice listview into the database? I want to save the status of a item from a list. For instance, if i have 2 items checked i want to save this status in the database.
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Sure fegol,
I assume you already set up the multiple choice listview. (if not, please check online there are heaps of them http://www.androidpeople.com/android-listview-multiple-choice-example).
Here I’d like to give you some hint on data-saving problem.
Basically, there are two common choices. The first is to use getCheckedItemIds() or getCheckedItemPositions() on your listview (http://developer.android.com/reference/android/widget/AbsListView.html#getCheckedItemIds()).
The second one which is more flexible is to write a custom adapter. You can use isChecked() to check whether the checkbox was checked, and then save the status into your hashmap. Then you can get all status of checkboxes at the last.
I put some pseudo-code for the second approach for you. Hope this helps.