Question

I need to get the "Documents" path from C code working under Android. The analogs for different OSs are:

On Windows:

SHGetKnownFolderIDList(FOLDERID_Documents, ...) 

returns the path to "My Documents" folder.

On iPhone:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];

One solution is to call some Android high-level function through JNI (which function, by the way?). But is there a native function?

Was it helpful?

Solution 2

So, I'm going to use Android API (through a JNI call) and create the necessary folder for native data. So, it's the function

getApplication().getDir("NativeData", Context.MODE_PRIVATE).getAbsolutePath(),

that suits me.

OTHER TIPS

There is no standard "Documents" path in Android.

You can see the standard public directories in the DIRECTORY_* constants defined on the Environment class. AFAIK, there is no way to get the location of those from within the NDK, other than to pass it in from Java -- you get the directory in Java from the getExternalStoragePublicDirectory() method on Environment. And none of them are "documents" -- DIRECTORY_DOWNLOADS is perhaps the closest match.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top