android - Are all .class files in my Java application loaded into memory after appliaction start? -


I'm making an app for Android, in my activity I need to load an array of about 10000 strings. Loading it from the database was slow, so I decided to keep it straight in a .java file (as a private area). I have about 20 classes which are string arrays and my question is is whether all the applications have been filled in memory after my start? If so, the activity in which I need these stars will be loaded quickly, but the application will start at a slow speed ... is there any other way, how fast the 10000 string array from a file loads To do?

Update: Why do I need these strings? My Android app allows you to find "travel" in Prague's public transportation - you choose to stop the departure, stop the arrival and it looks at your visit (there is a look). My app has a suggestion feature - you enter "C" as your exit stops and a suggestion list view is displayed with the stop that starts with "C". I need a wire for these suggestions Databases suggestion Receiving is slow (G1 about 400ms).

First of all, I doubt that the query to 400ms database is really slow so slow Had there been some problem with your database schema (like index) or your database connection configuration. But if you are serious about not using a database, then there are two alternatives to the options you are currently doing:

  1. Arrange that sections containing arrays < Using Code> Class.forName (...) , is loaded as needed. If you apply it correctly, then it may be possible for the garbage collector to recover the classes after they are loaded and the string has been added to your primary data structure.

  2. Put 10000 strings in a successful file, file the file into your app's jar file. Then use Class.getResourceAsStream (...) to open the file and read it in the in-memory array.

  3. In the form of the above, but instead of using an indexed file and data structure, the array is replaced by the array which lets you lazy to read the strips from the file (this little bit It would be complicated, but if you are worried about the memory consumed by 10000 strings, then it will help to find out.)


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -