Skip to content

User data import export#114

Merged
intermarc merged 7 commits intomasterfrom
user_data_import_export
May 10, 2026
Merged

User data import export#114
intermarc merged 7 commits intomasterfrom
user_data_import_export

Conversation

@intermarc
Copy link
Copy Markdown
Collaborator

This branch adds functionality to import and export database tables with user data, which could be useful when migrating to a new device or to just have a backup. In particular, the data exported/imported includes:

  • Talk, teacher and center stars (favorites)
  • Talk playback history

Import and export are based on .sqlite3 files and use the android file picker, such that the app does not require additional storage access permissions. The following image illustrates the import process:
import_export

Imported tables are merged with existing tables in the app. For the "star" tables, this is a straight forward union. For the history table, conflicts are resolved by retaining the talk playback progress with the most recent access date.

…rate function

- added functions to import/export history and star tables to external sqlite3 file
…itNavigationDrawer

- lots of code just to add icons to the new import/export buttons :)
- new functions for importing/exporting user data to storage using the android file picker and new functionality in DBManager
- success and error messages for import and export
@intermarc intermarc requested a review from bb4242 April 25, 2026 19:36
@intermarc
Copy link
Copy Markdown
Collaborator Author

The last commit has nothing to do with the import/export feature. I just noticed that www.dharmaseed.org links were not being redirected to the app! This might explain some seemingly inconsistent behavior that we noticed in the past.

Copy link
Copy Markdown
Collaborator

@bb4242 bb4242 left a comment

Choose a reason for hiding this comment

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

This looks great to me! Thanks @intermarc. I've tested the changes locally and everything works as expected. I think this will be a really nice feature both for users and for us while doing development (where I often find myself wiping out my database as I install and uninstall development versions of the app).

copyStreams(dbIn, dbOut, true);
}

private void copyStreams(InputStream src, OutputStream dest, boolean closeAfterCopy) throws IOException {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think all uses of this method call it with closeAfterCopy = true. Would it make sense to just remove this parameter?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, of course. Good idea!

);
}

private void addDBIcons(MenuItem item, String baseText) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In an ideal world, I think it would be nice to be able to embed these icons directly inside of the drawer_import/drawer_export resource strings, so we didn't have to write code to join the icons together with the text. However, I'm not aware of any way to do that, so I think this is the next best approach. 🙂

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

That would have been nice, yes. I was hoping to find a Unicode "History Clock" character, but no luck. As it is, the amount of code for the menu item is probably about the same as the actual import/export functionality! Oh well.

@intermarc intermarc merged commit 73fb045 into master May 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants