4

I am starting an activity with a Serializeable extra. This extra contains a List of a custom object holding a bunch of types, mostly Strings. I read in the data from the assets folder of my project, and parse it with GSON(the data is JSON). This file is ~108KB in size.

For the life of my application, all data is being passed around as intent extras. This is very convenient as i don't have to worry about re-loading the data from the assets folder again, app shutdown recovery is all taken care of, and i don't need to manage an SQLite database(versioning, queries, etc).

Problem: I find that passing these extras around can become quite slow(starting an activity with ALL the data takes maybe 1.5 seconds or more). I can't seem to show any "loading" dialog either, as it seems to be a blocking call to start an activity and attach extras.

Question(s): Should I avoid passing these extras around like I have described? Is the best option using an SQLite database to interact with this data? What suggestions do you have to avoid a lot of the fuss of SQLite databases/global static variables for accessing my application's data?

Slapping my JSON data into data model classes and passing them as intent extras is easy and nice(seemingly), and i don't want to give it up!

james
  • 26,141
  • 19
  • 95
  • 113

2 Answers2

2

I had the same problem and followed the solution you already depicted. I used an SQLite DB to store the information, then passed only unique ids as intent extra and displayed a "loading..." progress dialog on the called activity while I accessed the DB.

Prolly using SQLite is the way to go.

Hyperboreus
  • 31,997
  • 9
  • 47
  • 87
0

Why don't you load the data to the Application class, onCreate of the Application class, and then access from every activity there?

neteinstein
  • 17,529
  • 11
  • 93
  • 123
  • I would still have to check for an application shutdown on every create – james May 24 '11 at 13:16
  • True, but you can manage it: http://stackoverflow.com/questions/6063550/android-best-way-to-save-data-stored-in-application-singleton-class/ – neteinstein May 24 '11 at 13:39