2013-12-21 101 views
1

是否可以從SQLite數據庫填充ListView而不先將數據保存到Array或List?我的SQLite數據庫中有大約20000行數據。Android:直接從SQLite數據庫填充ListView - 無需使用ArrayList

謝謝!

+1

當然可以,http://stackoverflow.com/questions/12077955/android-using-simplecursoradapter-to-get-data-from-database-to-listview –

+0

使用遊標,你將在SQLite數據庫中查詢它。 – JJ86

回答

1

是的。這個有可能。使用SimpleCursorAdapter直接從數據庫填充您的ListView。爲避免在UI線程上執行數據庫操作(startManagingCursorstopManagingCursor),建議使用CursorLoader(由ContentProvider作爲後臺)以異步加載數據。更多... http://developer.android.com/guide/components/loaders.htmlhttps://developer.android.com/training/load-data-background/setup-loader.html

+0

謝謝!尼斯鏈接 – moritzg

+0

不客氣。 – Jimi