app-dirs-rs
                                
                                
                                
                                    app-dirs-rs copied to clipboard
                            
                            
                            
                        Support Android
I think trying to use this on Android would activate the unix branch and try to use the XDG spec... which I'm pretty sure that Android doesn't follow. :scream:
For Android, all the APIs are available through Java of course, and for this they're all in the Context object. I'm not sure if we can access this through Rust, or if there is an equivalent NDK API. Anyway, if this was a key-value store, we'd be using [getSharedPreferences](https://developer.android.com/reference/android/content/Context.html#getSharedPreferences%28java.lang.String, int%29) (returning a SharedPreferences object of course) which is a lot better than alternatives, but for an actual path I think getExternalFilesDir and getExternalCacheDirs would give us the paths we're looking for.
I wonder if either of these fields on ANativeActivity in tomaka/android-rs-glue would work? It seems like they're attached to the Activity struct, so not sure how we'd get to them without a handle to an instance...
Maybe, there's no cache dir though of course. Also, we've got the problem of getting the Activity as you mentioned, we wouldn't be the ones setting up the app.
Any news on this?
Zilch. Hence the "help wanted" label. I have no idea how to do this. 😞
https://developer.android.com/guide/topics/data/data-storage.html seems like the place to start
SDL2's filesystem path code does a sort of similar task so I thought it might be helpful, but doesn't look super hopeful: https://hg.libsdl.org/SDL/file/8df7a59b5528/src/filesystem/android/SDL_sysfilesystem.c
https://hg.libsdl.org/SDL/file/8df7a59b5528/docs/README-android.md has some useful information under "loading assets".
Looks like Android has some special functionality for static data in addition to normal filesystem paths, so it's not entirely trivial.
Thanks for the resources! I'll look into this when I have time. Need to get my hands on an Android device to test :) (Though I guess the simulator could work)
No problem. If I have to make a PR for this I will and I want these resources somewhere I can find them to. :D