Get the current(Java application) directory from native C lib.
1,450 views
Skip to first unread message
kris
unread,
Jun 28, 2012, 10:09:23 AM6/28/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to andro...@googlegroups.com
I developed mylib.so C-library. In mylib.so I need to create some folders based on current working directory(I use getcwd() C-function).
When Somebody creates application SomeJavaApp(which uses mylib.so) mylib.so tries to create and use folders... but WHERE? Nowhere! As fact, mylib.so needs to create folders somewhere like in /data/data/ru.android.some..../
The question is how to get this folder path(/data/data/ru.android.some) from mylib.so C-library, which knows nothing about SomeJavaApp at all? Maybe there is specific android-API function or somthing else. Is the question clear?
RichardC
unread,
Jun 28, 2012, 10:57:56 AM6/28/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to andro...@googlegroups.com
Make it part of the initialization of your lib that the Java code using your lib has to pass in the paths to internal and external application storage.
See:
Context.getDir
Context.getExternalFilesDir
kris
unread,
Jun 28, 2012, 11:29:30 AM6/28/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to andro...@googlegroups.com
You mean to put my folders(and my files) somewhere like ... /sdcard/myfolders/ and say to JavaApp to use the path /sdcard/myfolders? Or I didn't understand you?
четверг, 28 июня 2012 г., 18:57:56 UTC+4 пользователь RichardC написал:
kris
unread,
Jun 28, 2012, 11:31:56 AM6/28/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to andro...@googlegroups.com
Is the tricky way to get SomeJavaApp package name (ru.android.some.domain.app) from C-library mylib.so? SomeJavaApp is the app, which is not my software but it uses mylib.so.
RichardC
unread,
Jun 28, 2012, 11:37:40 AM6/28/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to andro...@googlegroups.com
On Thursday, June 28, 2012 4:29:30 PM UTC+1, kris wrote:
You mean to put my folders(and my files) somewhere like ... /sdcard/myfolders/ and say to JavaApp to use the path /sdcard/myfolders? Or I didn't understand you?
No just define a method in your C lib that follows the Java native Jni calling convention that takes 2 string as parameters. Then tell the people using your lib to call the method from their Java code and pass in the paths for internal and external storage.