Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
jaybb
Posts: 32
Registered: ‎03-06-2009
My Device: Not Specified

Is there a concept of local storage area for the app, separate from the SDcard?

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?

Thanks

Jay 

Developer
johnbibs
Posts: 905
Registered: ‎02-07-2009
My Device: BlackBerry Torch 9800

Re: Is there a concept of local storage area for the app, separate from the SDcard?

is it the same app who's gonna read those files? if yes then just use persistence storage. these are meant for apps. 

New Developer
jaybb
Posts: 32
Registered: ‎03-06-2009
My Device: Not Specified

Re: Is there a concept of local storage area for the app, separate from the SDcard?

It's the same app that will read the files. In persistent storage, can you write files? I thought it was only for an "object datastore" where you stored serialized objects.
Developer
johnbibs
Posts: 905
Registered: ‎02-07-2009
My Device: BlackBerry Torch 9800

Re: Is there a concept of local storage area for the app, separate from the SDcard?

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 :smileyhappy:  

New Developer
jaybb
Posts: 32
Registered: ‎03-06-2009
My Device: Not Specified

Re: Is there a concept of local storage area for the app, separate from the SDcard?

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.

thanks

jay

 

Developer
Ted_Hopp
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: Is there a concept of local storage area for the app, separate from the SDcard?

Persistent store can work just fine. Instead of writing to an output stream going to a file, write to a ByteArrayOutputStream. Instead of a collecction of files accessed by name, you can use a hash table (for instance) to hold a collection of byte arrays accessed by key. It's pretty easy to build an abstract data management layer that works equally well with persistent store and the file system.



Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Developer
johnbibs
Posts: 905
Registered: ‎02-07-2009
My Device: BlackBerry Torch 9800

Re: Is there a concept of local storage area for the app, separate from the SDcard?

you can also use the device memory instead.:smileyhappy:
Developer
Ted_Hopp
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: Is there a concept of local storage area for the app, separate from the SDcard?

The device memory (if you're talking about store/) has the same problem as the sd card: the files remain when the app is removed.



Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Developer
johnbibs
Posts: 905
Registered: ‎02-07-2009
My Device: BlackBerry Torch 9800

Re: Is there a concept of local storage area for the app, separate from the SDcard?

yup, it still retains the files, but it's a different storage from SD. :smileyhappy: 

 

 

guess your only way to go is persistence. :smileyhappy: 

New Developer
lilbyrdie
Posts: 11
Registered: ‎08-21-2009
My Device: Not Specified

Re: Is there a concept of local storage area for the app, separate from the SDcard?

I had this same question. Luckily, there already seems to be a consensus answer.

 

Except, seriously??

 

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.