BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 01-28-2009, 02:08 PM   #1 (permalink)
New Member
 
Join Date: Jan 2009
Model: Storm
PIN: N/A
Carrier: Verizon
Posts: 8
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Writing files to disk

Please Login to Remove!

I need my app to do a little caching and so would like to write a few small files to disk. It looks like there are half a dozen ways to store data in the API. Looking through forum posts, the most common method I see is the FileConnection method which looks like it will work great.

One question - Where should I store my files? Is there any convention on where app data should be stored? Most examples I see are reading and writing to the /store/samples/... directories which seems weird to me.

Does anyone know of a good tutorial on reading and writing to disk on blackberries?
Offline  
Old 01-28-2009, 04:07 PM   #2 (permalink)
New Member
 
Join Date: Jan 2009
Model: Storm
PIN: N/A
Carrier: Verizon
Posts: 8
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Followup question: As this file is going to be used as a cache of sorts, I would rather not have it be browsable on the device if possible, so if I could keep it out of the base directory structure that would be much better.

Is there anything like the hidden application_data directory on a Window's machine? Or even better, is there anything parallel to the sandboxing infrastructure provided on the iPhone and Android platforms which gives you a place to store files which only your app can access?
Offline  
Old 01-28-2009, 08:08 PM   #3 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default

Sounds like what you want to use is the PersistentStore.
Offline  
Old 01-29-2009, 12:25 PM   #4 (permalink)
Knows Where the Search Button Is
 
Join Date: Sep 2007
Location: Delaware
Model: 8310
Carrier: AT&T
Posts: 23
Post Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up

Yes. The PersistentStore will work but keep in mind that using this will require you to get keys to sign your application. Otherwise you won't have the authority to run your application on the device -- it will run on the emulator, however.
Offline  
Old 01-29-2009, 12:39 PM   #5 (permalink)
New Member
 
Join Date: Jan 2009
Model: Storm
PIN: N/A
Carrier: Verizon
Posts: 8
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have looked into the persistentStore, and it would be ideal. However, although the API does not really specify size guidelines, in a different forum post I read that the persistentStore was somewhat limited in space. I am not sure what 'limited' means. While the cache would usually be quite small, in the rare case it would have the potential to grow as large as 30-40 Mb.

Does anyone know the limitations of the persistentStore?
Offline  
Old 01-29-2009, 01:29 PM   #6 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default

Check out this thread for size limitation.

You may be back to FileConnection which would allow you to write to an SDCard. 30-40 Mbytes would be pushing the limits for internal storage except for the Bold or Storm. Older devices only have 64MB of memory, and some of that is going to be used for other things.
Offline  
Old 01-29-2009, 02:01 PM   #7 (permalink)
New Member
 
Join Date: Jan 2009
Model: Storm
PIN: N/A
Carrier: Verizon
Posts: 8
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks. That is exactly what I was wondering.

Which kind of brings me back to the original question. If I have to store it in the traditional directories, is there a conventional place to store application data, or do I just put it in something like:

/store/home/user/[my_app]/[my_cache_data]
or
/SDCard/BlackBerry/[my_app]/[my_cache_data]

Out of these, I guess I would have to use the second. I am sure the first stores on the memory of the device which faces the same problems and the persistentStore
Offline  
Old 01-30-2009, 08:01 AM   #8 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default

Yes, that is correct (though I'm not certain about the path you specify for device memory). The problem is that files on the SDCard won't have the protection you were looking for. Since you have a Storm you could make PersistentStore work for you, but your users may not be so lucky.

Last edited by hrbuckley : 01-30-2009 at 08:05 AM.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.