08-13-2009 02:18 PM
My app needs to write files, and read them later. At present I am writing these to the SDCard:/documents folder but clearly this is not meant for apps, it is meant for the user. I could serialize the files as objects into the persistent data store my app uses, but that seems like a lot of (inelegant) work for just basic file i/o.
iPhone and Android provide a basic area below where the app is installed where the app can write files. When the app is uninstalled these files are deleted as well (on Android, optionally).
Is there any such area available to BlackBerry apps, and whats the Java API to access the same?
08-13-2009 05:56 PM
08-13-2009 06:04 PM
yup its for data store. so for example in my application i need to send a file from an application server, what i do is, stored the information in the persistence storage then when i need to send the file, that's the time i create a File object and write those info from the persistence, then send it to the app server.
why would you write it in a file if your app is the only one who will read the files? do you want it to be editable for example in a text editor maybe? just want to understand where you're coming from so i can help you
08-13-2009 06:21 PM
my app is a kind of temporary-file sharing app. So it may receive different kinds of files like audio, text, zip, pictures, etc. I would like to be able to write them out as is, when received, and read them and render them as needed later by the user, and if the user desires, save them out to the proper location on the SDcard.
So is the persistent store still an appropriate and easy place to do this? Currently I am using a folder in the SDcard for this, but I'd rather not do that except for the files that the user explcitly wants there.
08-13-2009 06:31 PM
08-13-2009 11:32 PM
08-21-2009 12:43 PM
I had this same question. Luckily, there already seems to be a consensus answer.
Is the persistent store as good for storing large files? Say I want to store browser-type cache information (e.g. lots of large images, small files, and many other things -- all referenced by filename). Is persistentstore going to work as well in that scenario?
Many of the APIs I use take an InputConnection. That's convenient, since the file could cover over Http or File. But, it means creating another layer over the persistent object.
As with the OP, though, I don't want to clutter up the users space -- instead, I want file directory local to the app.
I come from the view where databases aren't used to store large objects -- instead, you store a reference to them and load the objects directly. And, PersistentStore looks like a basic key-value database. Is it not? Will it handle multiple megabytes going in and out frequently as easy and efficiently as the file system?
Finally -- and this may be the key -- how do you iterate over the objects in the PersistentStore? Do I always have to keep yet another store object (a Vector, for instance) around that keeps that information? That adds yet another level of indirection.
Anyway, just curious to get some more information about this. Nothing in the docs has led me to believe that PersistentStore is good for storing files -- but, that's the answer presented here.