Database access from Rust #5

Open
opened 2022-10-14 17:55:31 +00:00 by Lonami · 0 comments
Owner

It is possible to obtain a path which Rust can directly use to create and manage files, such as SQLite database files, with Context.getDatabasePath(file name).

A MainActivity has a context, so it's possible to call getDatabasePath directly. From within a Composable, it is possible to access the context via LocalContext.current, although this shouldn't be necessary.

The sqlite Rust crate seems run fine on Android.

It is probably not worth to worry about the fact access to the database would be blocking at first. If it becomes a concern, tokio::task::spawn_blocking can probably be used to help alleviate the problem.

It is possible to obtain a path which Rust can directly use to create and manage files, such as SQLite database files, with `Context.getDatabasePath(file name)`. A `MainActivity` has a context, so it's possible to call `getDatabasePath` directly. From within a `Composable`, it is possible to access the context via `LocalContext.current`, although this shouldn't be necessary. The `sqlite` Rust crate seems run fine on Android. It is probably not worth to worry about the fact access to the database would be blocking at first. If it becomes a concern, `tokio::task::spawn_blocking` can probably be used to help alleviate the problem.
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Lonami/Talaria#5
No description provided.