1

Is it possible to populate a ListView from a SQLite Database without saving the data to an Array or List first? I have about 20000 lines of data in my SQLite Database.

Thanks!

moritzg
  • 4,266
  • 3
  • 37
  • 62

2 Answers2

1

You can use CursorAdapter to achieve this. Here goes a tutorial: http://www.mysamplecode.com/2012/07/android-listview-cursoradapter-sqlite.html

Md. Arafat Al Mahmud
  • 3,124
  • 5
  • 35
  • 66
1

Yes. This is possible. Use a SimpleCursorAdapter to populate your ListView directly from a database. To avoid performing database operations on the UI thread (startManagingCursor and stopManagingCursor), it is recommended to use a CursorLoader - backed by a ContentProvider - in order to load data asynchronously. Read more... http://developer.android.com/guide/components/loaders.html https://developer.android.com/training/load-data-background/setup-loader.html

Jimi
  • 539
  • 5
  • 21