Skip to content

Find and use the right paths for the app database #1321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
PIG208 opened this issue Feb 4, 2025 · 1 comment
Closed

Find and use the right paths for the app database #1321

PIG208 opened this issue Feb 4, 2025 · 1 comment
Labels
a-Android Issues specific to Android, or requiring Android-specific work a-iOS Issues specific to iOS, or requiring iOS-specific work

Comments

@PIG208
Copy link
Member

PIG208 commented Feb 4, 2025

When launching the app for the first time, we use LiveGlobalStore._dbFile to find where the sqlite database file should be created at. This varies by platform, and we need to determine a best fit for each.

For iOS, it is suggested to

[u]se ["Library/Application Support"] to store all app data files except those associated with the user’s documents. For example, you might use this directory to store app-created data files, configuration files, templates, or other fixed or modifiable resources that are managed by the app.


For Android, it is more ambiguous, as I couldn't find an official recommendation. However, there is getDatabasePath intended to be paired with openOrCreateDatabase that we don't use. The path would look like /data/user/0/com.zulip.flutter/databases/. However, path_provider doesn't have a binding for getDatabasePath.

The other options are:

  • path_provider's getApplicationSupportDirectory (Flutter's PathUtils.getFilesDir -> getFilesDir -> empirically /data/data/com.zulip.flutter/files/, or /data/user/0/com.zulip.flutter/files from testing)

  • path_provider's getApplicationDocumentsDirectory (Flutter's PathUtils.getDataDirectory -> getDir with MODE_PRIVATE).

Neither requires additional permission to be created, and both refers to private storage.


We might also take the path on Linux in to consideration, while it is not a target platform.

We get "${XDG_DATA_HOME:-~/.local/share}/com.zulip.flutter/" for getApplicationSupportDirectory and ``xdg-user-dir DOCUMENTS -> e.g. ~/Documents for `getApplicationDocumentsDirectory`. The latter is clearly not a fit, and the former is more reasonable.

@PIG208 PIG208 added a-Android Issues specific to Android, or requiring Android-specific work a-iOS Issues specific to iOS, or requiring iOS-specific work labels Feb 4, 2025
@PIG208 PIG208 changed the title Find and use the right path for the app database Find and use the right paths for the app database Feb 4, 2025
@gnprice
Copy link
Member

gnprice commented Feb 4, 2025

The path we already use has been working fine. If we learn a reason it should change, we can open an issue for that then. (Chat thread.)

@gnprice gnprice closed this as not planned Won't fix, can't repro, duplicate, stale Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-Android Issues specific to Android, or requiring Android-specific work a-iOS Issues specific to iOS, or requiring iOS-specific work
Projects
Status: Done
Development

No branches or pull requests

2 participants