tags:

views:

52

answers:

1

Hi,

I am porting a c++ library code into android(which was initially written for linux).

The library is built and is used by a java application.

In the previous linux code, library used to create and update a log file in /tmp folder of the system... But unfortunately, there is no such temp dir in android.

Seems I cannot use use applications cache to save the file due to a few reasons.

1. User need to view the file after exiting the app

2. The library need to be reused by different applications in future. 

3. The log file is created by the native library(and not the java app)

(pls correct me if some/all of my understanding is wrong)

Also I found most of the directories are write protected in the default setting..

How can i tackle the issue, without 'rooting' the os? Pls help..

A: 

Modify the C/C++ code to use a directory supplied from the Java code. Have the Java code pass in some subdirectory you create under Environment.getExternalStorageDirectory().

CommonsWare
This will create a file in application's own cache, right?
Dhanesh
@Dhanesh: There is no "application's own cache" that meets your criteria #1. You are welcome to create a directory on the external storage that is named after your application, though.
CommonsWare
Thanks for the clarification.. Still, one more qn, What if i have no write permission in a common dir.. (Can i do it without 'rooting')?
Dhanesh
@Dhanesh: The external storage is writeable by everything that has the `WRITE_EXTERNAL_STORAGE` `<uses-permission>` element in its manifest. If your application hosting the NDK library lacks that permission, you will fail with an error.
CommonsWare