-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
  • 59,252
  • 19
  • 87
  • 137

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,469
  • 10
  • 42
  • 71
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
  • 4,875
  • 3
  • 29
  • 44