Skip to content

Added support for android local storage via set_dir! macro - #100

Merged
ealmloff merged 6 commits into
DioxusLabs:mainfrom
pvg13:main
Dec 26, 2025
Merged

Added support for android local storage via set_dir! macro#100
ealmloff merged 6 commits into
DioxusLabs:mainfrom
pvg13:main

Conversation

@pvg13

@pvg13 pvg13 commented Dec 19, 2025

Copy link
Copy Markdown
Contributor

Hi!

I added a small helper function to locate the Android directory for the storage SDK: data_directory.

It works as follows:

  1. Sets up a communication channel between the main Rust thread and the Android execution thread.
  2. Dispatches a closure to run on the Android/JVM thread where it has access to the Java environment (JNIEnv).
  3. Calls Java methods (getFilesDir and getAbsolutePath) to find where the app is allowed to save files.
  4. Converts the result from a Java String to a Rust PathBuf.
  5. Blocks and waits until the path is received, then returns it.

In the set_dir! macro if target_os = "android" it will make a call to the data_directory function to figure out the correct path for the app.

I don't know if this is the most elegant solution, maybe it's better to give the information via dx or something similar.

This probably also fixes: #99

Comment thread packages/storage/src/client_storage/fs.rs Outdated
Comment thread packages/storage/src/client_storage/mod.rs Outdated

@ealmloff ealmloff left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ealmloff
ealmloff merged commit 1552504 into DioxusLabs:main Dec 26, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dioxus storage in android

3 participants