05-15-2009 11:53 PM
I am attempting to port an app to BlackBerry which appends String data to a file. On the other platforms this isn't a problem because filesystem access is pretty straight forward and I just open the file for appending and it's easy to write the data. However, this data shouldn't be stored on the user's Compact Flash device, and when I try and access file:///store/ I get a permissions dialog on some devices which is not an option.
So it looks like I'm stuck with the persisted store. However, if the data ends up being large (say 100, 10 byte blobs), I don't want to be reading in and appending to an ever increasing string every time. Is there some clever object, or way to use the persisted store that allows me to append data without re-consuming everything that is stored?
05-16-2009 12:18 AM
It seems like the MIDP RecordStore object support inserting data at a given position:
public int addRecord(byte data, int offset, int numBytes);
Assuming there is no similar functionality with the PersistentStore, is this a better way for me to append data to persistent storage?
05-16-2009 12:23 AM
Nope that is completely wrong. The buffer / offset for that argument exist only to facilitate storing parts of the data. Using RecordStore does not allow appending of data without reading in the entire object, that I can tell.
Maybe somebody else will have an idea.
05-16-2009 05:46 AM
Use PersistentStore. For me the most compelling reason to use the file connection API is the size of the data. You don't want to put photos or videos in persistent Store. But in this case you are storing 100 10 bytes blob = 1,000 byes. This is very small by persistent storage standards. Also, using persistent store, adding a blob is very easy. Create your Persistent Store object extending Vector and you just add an element. You can consume everything by walking your Vector.
Minor point: external storage on a BlackBerry is SD Card not Compact Flash.
05-16-2009 11:59 AM
I signed my code, but on my older test device (8800) I get a dialog saying "app would like to access file:///store"
Do you have any advice on when the data becomes too great for the persisted store?
05-17-2009 05:50 PM
Signing allows the application to use RIM restricted APIs. Permissions are what the application is allowed, by the user, to do, so is not related to signing.
I don't think that I can give you much advice about when data becomes too big, because that depends on the device and the other applications on the device. However, given that the App Store application is 500 MB, I think you can persist quite a lot of data.
05-17-2009 05:55 PM
"You can consume everything by walking your Vector."
Presuming you want to actually find it however, I would advocate some type of indexing system.
You could even call it a database if that matters