File created in NDK - How to access that from UI app?

37 views
Skip to first unread message

SathishKumar Mani

unread,
Feb 16, 2010, 1:12:26 AM2/16/10
to andro...@googlegroups.com
Hi,
I would like to do the following, please advice the best solution
- In my native library I will be creating files. File location is /data/data/com.example.remote_service/files/test.txt. (I am able to do that. No issues)
- I want the UI app running in a different process to access these files created by my Native library.( I am having trouble here)

I am not sure what permissions I have to explicitly set so that my UI app can directly access this file using JAVA api's.
I tried using openFileInput() with the absolute path and I got an error and after reading the documentation noticed that I cannot use absolute path for openFileInput().

Is ContentProvider the only option for me or are there any other way to access these files from the UI App.

Appreciate any solution/pointers...

Thanks
Sathish

Dianne Hackborn

unread,
Feb 16, 2010, 11:05:36 PM2/16/10
to andro...@googlegroups.com
(1) Please use the Context APIs to get the path at which you should store files.  In the future there WILL BE different base paths where data can go, so you don't want to hard-code this.

(2) Now that you are using the Context APIs, you can also use them to access the files from Java.

(3) If your code is all in the same .apk, it can all access the same files, regardless of what process it runs under.  All of the processes will be running as the same uid, and thus have permission to access the same files.

(4) If this code is running in different .apks, they will typically have different uids, so simply can't directly access each others' files.  This is where content providers come in, or sharedUserId as a brute force solution.

--
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.



--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

Reply all
Reply to author
Forward
0 new messages