2

If I want to use an AutoCompleteTextView as a search function to generate a list of strings (let's say about 1000-3000 strings) based on the text the user has currently inputted, would it be better to be loading these strings from an external database or having them stored in the internal SQLite database and loading the strings from there?

Is the amount of strings I plan on storing too big (each string will be about 10-20 characters long, they are constants and will never change) to be used in the SQLite database? How much would this slow down and/or bulk up my app? Should I just use the external database? Would the loading times be fast as the user is typing in a string?

I'm asking because if I can avoid using an external database I would prefer that since I wouldn't have to worry about the number of users accessing the database, maintaining it, and security issues.

David Velasquez
  • 2,346
  • 1
  • 26
  • 46
  • 10-20 characters can be considered as short, I think you can store that in a local database with no issue. Just make sure this solution will be flexible enough for you, i.e. you don't run into issues updating your local database, etc. – Gennadii Saprykin Apr 26 '16 at 01:17

1 Answers1

1

would it be better to be loading these strings from an external database or having them stored in the internal SQLite database and loading the strings from there?

Depends on what you mean by 'better'. If you store them in a local database then the performance should be better, I recommend using indexes in this case. At the same time, this solution will require more memory although I think 3000 strings should be okay if they are just one-word strings.

Is the amount of strings I plan on storing too big to be used in the SQLite database?

Depends on what are those strings. If they are not too long then I think it should be fine. If each string contains a lot of text then I think this might cause problems while searching through them via SQL queries.

How much would this slow down and/or bulk up my app?

It shouldn't be noticeable, you can actually create a test for that, shouldn't take a lot of effort. Depends on your use case.

Should I just use the external database?

If those strings are like constants and they are not going to change, you can consider storing them in a local database, this should improve the performance versus the network-loading solution.

Would the loading times be fast as the user is typing in a string?

You can load the first set of data when they 'stop' typing. See my answer to similar question here: Best Practices for Handling Search

Once you load the list of data you can use this local cache for further searching, it should be fast enough so that user doesn't notice any delay.

Community
  • 1
  • 1
Gennadii Saprykin
  • 4,505
  • 8
  • 31
  • 41