0

I'm kind of new to android, and I don't have the global view needed to find the right way to solve my problem.

I want to include in my application a big list of blobs. Those blobs should be available by index in the list, without loading the whole list in memory. What I actually want to do is a dictionary-like app, and I need to access definitions by index to display them in a ListView or a PagerAdaper, but there are a few Mo of data and I don't want to load it all in memory.

I've though of a few approach, but none of them seems optimal and I could use some insight :

  • Use a sqlite database, but according to a quick research, it's not possible to use a resource sqlite file. I would have to copy the data into a private database, and that would waste some Mo.
  • Make it myself from scratch : it shouldn't be too hard to have a big file with all the data and an index file with the seek index for each entry.

Am I right about sqlite not being usable without data duplication ? Are there any better ways to do it than from scratch ?

madjar
  • 12,691
  • 2
  • 44
  • 52
  • What do you mean by data duplication. – Simon Nov 06 '12 at 14:38
  • I just mean having the data into an internal database while also having it in a resource file. (As discussed there : http://stackoverflow.com/questions/513084/how-to-ship-an-android-application-with-a-database) – madjar Nov 06 '12 at 14:51

1 Answers1

1

I want to include in my application a big list of blobs.

From the context of the rest of your question, I am assuming that the "big list of blobs" would be a resource. Doing it this way is an exceptionally bad idea, IMHO, and flat out will not work if the "big list of blobs" is over 1MB.

I would break up the "big list of blobs" into individual resources per blob, and perhaps have a separate resource (raw or XML) that is your index, if individual resource IDs are insufficient for you to find what you need.

IOW, there is no benefit at runtime -- and a lot of costs -- for keeping it all in a monolithic "big list of blobs".

Am I right about sqlite not being usable without data duplication ?

Yes.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • So, a lot of files and rely on the filesystem instead of making my own index. Okay ! Thanks a lot ! – madjar Nov 06 '12 at 17:46