Search code examples
androidapiunixfilesystemslow-level

UNIX/Android low-level API: need to get "Documents" path


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?


Solution

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