Question

I try to search through the questions to see if there is any similar thread to my problem but so far haven't found any. Here is my problem is: I have a list of products which contains ~10,000 items stored in a SQLite db. In my app, I need to search for any item from this list. I have a few options:

  • Use the autoCompleteTextView, with all products preloaded, and as I type the product's name, the list will suggest the product, hence I just need to select from the suggestion. This is the simplest way but I feel 10,000 items (or even more in the future) would be very heavy to load
  • As I type any character and click search, the app will do a select all products from the db with the character as a filter. The result set is then fed to some list view so that i can pick any item. This approach would save the memory as the app won't load all items to the memory but only items that contain the filtering characters.

Is there any better way to do this? Thanks

Was it helpful?

Solution

Your second option is the best way. Its similar to how you get a list of recommended search results while you type in your query. For you, assuming your using asynctask to query your db you can have a proper loading message signaled by onProgressUpdate

OTHER TIPS

Can you categorize the items? So that you can use use spinner to select the category, and use AutoCompleteTextView to type and select items.

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