-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
  • 63,869
  • 20
  • 92
  • 144

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,559
  • 11
  • 43
  • 72
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
  • 5,092
  • 3
  • 32
  • 45