Skip to content
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

feat: add external path support #822

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

lucasdidur
Copy link

Add support for Floor to set a external path to load/save database. App need to have storage permission managed by Permissions Manager.

  Future<AppDatabase> get appDatabase async {
    String externalPath = await ExternalPath.getExternalStoragePublicDirectory(
      ExternalPath.DIRECTORY_DOCUMENTS,
    );
    var dir = Directory(p.join(externalPath, 'My App'));
    if (!dir.existsSync()) {
      dir.create(recursive: true);
    }

    return $FloorAppDatabase.databaseBuilder(p.join(dir.path, DATABASE_NAME)).build();
  }

@ryanheise
Copy link

I like this PR. For most apps, the database should probably not be stored where this package wants to store it - path_provider.getApplicationSupportDirectory() would be better in most cases. The sqflite documentation says as much, and suggests not using getDatabasesPath() in favour of using path_provider directly, and constructing your own database path to pass into the API.

@dfdgsdfg
Copy link

@stephanmantel
Seems good to enough to merge. What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants