How can I delete the database from the application?
4 Answers
File dbFile = getDatabasePath("your_db_file_name");
boolean deleted = dbFile.delete();
4 Comments
DeRagan
If your phone is not rooted and if your database is inside your application folder(data/data) i doubt whether this can delete it.
plugmind
You may delete it inside an application in which you created it.
Teknogrebo
I've tried that approach on my database and it refuses to be deleted. I don't use getDatabasePath() as I create the database on the sd-card, but File.delete() always returns false. Is there anything else I need to call on the database itself other than close() to allow the file to be deleted?
user697495
DO NOT simply delete the file. Look at SQLiteDatabase#deleteDatabase and notice how it also deletes metadata files associated with the db: grepcode.com/file/repository.grepcode.com/java/ext/…
Do you need to delete the actual db file or is it enough to just DROP the tables? I'd imagine the end result is the same and dropping the tables could be easier.
1 Comment
Amit Thaper
i want to delete the actual db file