1

I try to figure out how to delete all created files from ObjectBox. During my unittest ObjectBox creates the needed files in the directory that I'm giving it on my local machine. After the unittest I want that ObjectBox deletes all the created files. How is that possible? I have seen in post like this one (How to close Objectbox Store and delete data files), that in JAVA is a "deleteAllFiles" method. For Flutter/Dart I can't find that one.

1 Answer 1

3

If you want to delete the files you can do something like

void deleteDbFiles() async {
    Directory docDir = await getApplicationDocumentsDirectory();
    Directory(docDir.path + '/db_name').delete();
}

Or you can use this, which would delete the entire directory (not recommended, only use if you're not using the default directory)

docDir.deleteSync(recursive: true);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.