2

I have the following scenario: I am parsing a JSON Response from a server into a sqlite database and then I am using the database and datamodels for querying, filtering, ...

A colleague of mine, an iOS developer, says, that he doesn't do JSON parsing into datamodels and persistence into database anymore. He just takes the dictionaries, makes them app-wide available and for persistence saves them into a binary file.

Now I would like to know, does anybody do it the same way on Android? Will it be a problem to have say 1000 HashMap-Objects in the App (each having about 10 other Objects (Strings))? Seems quite much to me, will it drop my app performance? But why does it work well on iOS?

Tobi
  • 168
  • 1
  • 12

3 Answers3

2

We do both in different projects. One project that we keep the data in json has a lot of different fields and some tree structure, so storing it to a DB would be a lot of busy work. However, we have run into memory issues because of the size.

To make your data life easier, and to have a rough parallel to CoreData, take a look at http://ormlite.com/. Its an orm tool that works with Android/Sqlite. I did the initial Android port and use it in pretty much every project I do. If you have a lot of data and only access small parts, database is potentially better.

1000 objects wouldn't really kill you either way, but its project specific and hard to say. I don't think keeping Json in memory is going to be any better on either platform, however. At least not orders of magnitude.

Kevin Galligan
  • 16,159
  • 5
  • 42
  • 62
  • Thanks a lot. I am trying it now, but maybe in my next project I will have a look at ormlite. – Tobi Nov 04 '11 at 18:57
0

Do you want to persist the data? If you want it to be accessible from one application run to the next, you have to persist it by doing something like storing it in to a file. I find that a database is easiest, but I guess if you really want to you can put it in some sort of binary file. But then you have to worry about how to go back and forth from that serialized data.

If you'd rather keep everything in memory during the life of your application, that's fine. You probably will notice some speed increases. And a 1000 object HashMap should fit in your memory just fine.

Kurtis Nusbaum
  • 30,445
  • 13
  • 78
  • 102
0

I can't tell from your colleague's description, but his implementation might be using CoreData, an iOS facility that doesn't have a parallel in Android. The description you provided matches it at a high level. Other ways of addressing that functionality on Android have been addressed here.

Community
  • 1
  • 1
jbm
  • 1,482
  • 11
  • 26
  • It seems he doesn't use CoreData, because he states he's just using the plain dictioniaries. – Tobi Nov 05 '11 at 08:05