app-dirs-rs icon indicating copy to clipboard operation
app-dirs-rs copied to clipboard

Support Android

Open andybarron opened this issue 9 years ago • 8 comments

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:

andybarron avatar Oct 27 '16 22:10 andybarron

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.

PlasmaPower avatar Oct 28 '16 04:10 PlasmaPower

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

andybarron avatar Oct 28 '16 06:10 andybarron

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.

PlasmaPower avatar Oct 28 '16 13:10 PlasmaPower

Any news on this?

TatriX avatar Oct 09 '17 18:10 TatriX

Zilch. Hence the "help wanted" label. I have no idea how to do this. 😞

andybarron avatar Oct 09 '17 18:10 andybarron

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.

icefoxen avatar Oct 09 '17 20:10 icefoxen

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)

andybarron avatar Oct 10 '17 01:10 andybarron

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

icefoxen avatar Oct 10 '17 12:10 icefoxen