You can use fopen(). You should probably use Java
android.content.Context methods to find useful pathnames (getFilesDir,
getExternalFilesDir, getCacheDir, etc. also
Environment.getExternalStorageDirectory) and then pass those in to
your native code.
What happens to data depends on where you put it. External (SD card)
stuff *except for getExternalFilesDir* gets left behind; everything on
the internal flash gets deleted when your app does. The docs for the
various functions seem to do a pretty good job of explaining the data
lifetime implications.
- Gus
How long is a piece of string? Realistically, I found using more than
a few megabytes of internal flash is enough to inconvenience users.
If you can store them in the cache directory though (getCacheDir),
Android will automatically delete them when the internal flash space
runs low (I think <10MB), which is great for files you can
recover/regenerate later.
> I presume that if I put them on the SD card that I must deal with the fact that the card
> may be removed?
Correct. I believe Froyo has some extra classes to help with that,
but (for example) my app needs the SD card at runtime and I just check
Environment.getExternalStorageDirectory().canRead() at startup and
prompt with a suitable error if the SD card is missing. If someone
removes it while I'm running then I'll crash. Meh.
- Gus
> On Jun 1, 7:47 pm, Angus Lees <al...@google.com> wrote:
>> On Wed, Jun 2, 2010 at 09:54, John Gaby <jg...@gabysoft.com> wrote:
>> > I would like to create data files for my application. If I try and
>> > use fopen("xxx", "wb"), it fails (I presume that it does not have
>> > permission to create the file in whatever the 'current' directory
>> > is). Where exactly can I store data files? How do I get the paths?
>> > Can I use fopen? What happens to the data files when my application
>> > is deleted?
>>
>> You can use fopen(). You should probably use Java
>> android.content.Context methods to find useful pathnames (getFilesDir,
>> getExternalFilesDir, getCacheDir, etc. also
>> Environment.getExternalStorageDirectory) and then pass those in to
>> your native code.
>>
>> What happens to data depends on where you put it. External (SD card)
>> stuff *except for getExternalFilesDir* gets left behind; everything on
>> the internal flash gets deleted when your app does. The docs for the
>> various functions seem to do a pretty good job of explaining the data
>> lifetime implications.
>>
>> - Gus
>
> --
> You received this message because you are subscribed to the Google Groups "android-ndk" group.
> To post to this group, send email to andro...@googlegroups.com.
> To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
>
>