Best practice for storing large amounts of data with J2ME

后端 未结 8 469
没有蜡笔的小新
没有蜡笔的小新 2020-12-03 08:50

I am developing a J2ME application that has a large amount of data to store on the device (in the region of 1MB but variable). I can\'t rely on the file system so I\'m stuck

8条回答
  •  遥遥无期
    2020-12-03 09:20

    For read only I'm arriving at acceptable times (within 10s), by indexing a resource file. I've got two ~800KB CSV price list exports. Program classes and both those files compress to a 300KB JAR.

    On searching I display a List and run a two Threads in the background to fill it, so the first results come pretty quickly and are viewable immediately. I first implemented a simple linear search, but that was too slow (~2min).

    Then I indexed the file (which is alphabetically sorted) to find the beginnings of each letter. Now before parsing line by line, I first InputStreamReader.skip() to the desired position, based on first letter. I suspect the delay comes mostly from decompressing the resource, so splitting resources would speed it up further. I don't want to do that, not to loose the advantage of easy upgrade. CSV are exported without any preprocessing.

提交回复
热议问题