Search code examples
databasefluttersqflite

Delete Database in Sqflite package in flutter


I am using the package 'sqflite' in flutter and I could not find a way to delete the entire database when the user in my app clicks on 'Delete Account'.

There are methods to delete data in a table but is there a way to delete the entire database using the package?


Solution

  • There is a delete database function in the DatabaseFactory that can delete a database based on path.

    Future<void> deleteDatabase(String path) =>
        databaseFactory.deleteDatabase(path);
    

    See documentation for more information: https://pub.dev/documentation/sqflite_common/latest/sqlite_api/DatabaseFactory-class.html