File IO tutorial?

rfresh

Well-Known Member
Licensed User
Longtime User
I need to save some data to a file and then read it back into a variable. Is there a tutorial showing me some examples of doing file io?

I understand that I should not try to write to an sd card since not all devices will have one. I assume it's recommended that I create a folder for my app to write the data to? My have a very small amount of data to store.

Thanks...
 

rfresh

Well-Known Member
Licensed User
Longtime User
What is the generally accepted standard for where we should write our data? Should I make a folder off of the root for my app? Or is there another, recommend location?
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
While not all devices will support and SDCard, they will need some form of additional memory to install apps on, I have seen refferred to as NAND on some devices. This is still external memory as far as Android is concerned and can be accesses via File.DirRootExternal or File.DirDefaultExternal (app installation folder) which is treated the same as the SDCard on devices that don't have NAND.

It should also pass the File.ExternalWritable test see here
 
Last edited:
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
So, I want to be writing my file data to External storage? (NAND or SDCARD)

On my Droid3 I see the following folders off of the root:

sdcard
sdcard-ext
sys
system
tmp

That's it.
 
Last edited:
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Yes use File.DirDefaultExternal or File.DirRootExternal and a path if you want it somewhere different.
 
Upvote 0
Top