-1

I'm programming an Android application and one feauture is a ListView generated and populated by a MySQL Database.

This is the outputted ArrayList:

DatabaseHandler db = new DatabaseHandler(this); 
List<Suspect> list = db.getAllContacts();

Do I use a cursor to input it in my ListView? Any code would be appreciated..

GoZoner
  • 67,920
  • 20
  • 95
  • 145

2 Answers2

1

I recommend you to use CursorAdapter in case you don't need any data manipulations after the query.
If you want to use List so try ArrayAdapter.

NickF
  • 5,637
  • 12
  • 44
  • 75
1

If you need to modify the data after it is captured from the database and have the view updated I'd suggest you create an arrayList of , and then you can use a custom Array Adapter like shown here. If you then change the underlying data, you can use adapter.notifyDataSetChanged()

rcbevans
  • 7,101
  • 4
  • 30
  • 46