There is a .txt file with a list of cities and their parameters (id, name, lon, lat, country, etc.) weighing 3.5 MB.

There is an application on android with SearchView in which only the name is required for the search query among the above data.

Actually the question is - in what way in the application to initialize such a list of data?

The first thing that came to mind was to write a small utility that converts the whole thing in json with the names of cities and in the search adapter that generates the necessary data for SearchView to work with them, and just stick it into the root of the project. But I am sure there are a lot of ways - which you can advise for use on the android platform, because there are quite strict requirements for optimization because of the iron of these devices.

And respectively the next question. The list of these cities after processing will be stored by the list inherited from the List , which option will be more suitable given that in the future this list will be converted to a MatrixCursor ?

  • Generating an index file is the best thing; it’s better to only index it into separate files. - etki
  • 2
    And why on the basis of this not to make a regular database (sqlite) and further on the tutorials? - KoVadim
  • @KoVadim is already used by the database, but a bit for other purposes and a bit different. This list is needed only for searchview. Or do you suggest just keep this list using the database? - abbath0767
  • 3
    Yes, keep this list in the database. This will greatly simplify your life. - KoVadim
  • one
    DB is the most sensible choice in your situation - pavlofff

1 answer 1

On the advice of @KoVadim, when I first start, I initiate a fill out database (orm = realm) with values ​​from the .txt file. Then in the query(...) method I work directly with the database, getting a List my data. Unless there was another problem - as I understood it with realm 'om you cannot work without your own bikes because it does not support the content providers architecture and, it seems, cannot return an ordinary cursor