Question

I am populating the ListView from my Custom DataAdaptor. I have a layout defined for each item/row of the listview. Inside that ListView i have an AutoCompleteTextView. I need to bind it with data from SQLite database. Actually this AutoCompleteTextView will list categories & these categories will come from a SQLite Table.I can bind it in my Custom DatAdapeter class inside getView() but i don't know how to avoid the multiple calls to the SQLite database?

As the categories will remain the same for each row so i want to get the Categories just once from the database & bind it with AutoCompleteTextView in each row.

Can someone guide me how to do it?

Regards.

Was it helpful?

Solution

To avoid multiple database calls ..

You can fetch data in cursor from database in your activity's onCreate() then using CursorAdapter or SimpleCursorAdapter bind it (using setAdapter) to AutoCOmpleteTextView in your list Adapter's getView()..

This example will help you lot Using AutocompleteTextView with SQLite and CursorAdapter

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top