-
-
Notifications
You must be signed in to change notification settings - Fork 528
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
Closing database and then open it #223
Comments
Not sure what you mean by failed. Is it throwing an exception? |
This is what I am getting: Is my openDB method ok? initDB is as following: |
Please try to wrap your code with ``` (triple ticks) as it is hard to read. Are you sure you are getting the error during initDB? Is it throwing an exception here? it seems to happen in some other places where indeed the database has been closed before. It seems also that you are trying to open the database twice (in initDB and openDB). I know it is a pain but can you try to reproduce the issue in a smaller scenario and share your project as it is impossible to help you more without being able to run the code. thanks! |
Below is my code:
This is the calling method:
|
It seems |
Many many thanks it wroked after I set _database = null. |
where i write _database = null |
Inside the close method, like this:
|
I also facing that problem any solution |
I tried issue # 184 https://github.com/tekartik/sqflite/issues/184 without any success. Please help.
I need to close the database as I need to put the file in a zip file for uploading. Closing is successful but it's not opening afterword. Below is my code:
closeDB() async {
final db = await database;
await db.close();
}
openDB() async {
Directory documentsDirectory = await getApplicationDocumentsDirectory();
String path = join(documentsDirectory.path, "TestDB.db");
return await openDatabase(
path,
version: 1,
onOpen: (db) {},
);
}
for executing:
await DBProvider.db.closeDB();
encoder.addFile(File('${documentsDirectory.path}/TestDB.db'));
await DBProvider.db.initDB();// failed
await DBProvider.db.openDB();// failed
The text was updated successfully, but these errors were encountered: