开发者

How to delete database in Android app

开发者 https://www.devze.com 2023-01-13 21:09 出处:网络
How can I delete the databa开发者_如何学编程se from the application?Did you check deleteDatabase() method available in Android?File dbFile = getDatabasePath(\"your_db_file_name\");

How can I delete the databa开发者_如何学编程se from the application?


Did you check deleteDatabase() method available in Android?


File dbFile = getDatabasePath("your_db_file_name");
boolean deleted = dbFile.delete();


Old post, but I think its worth adding this in case this feature wasn't available back then. I use Context. For example, when your in MainActivity

this.deleteDatabase("mydata.db");

or when you have a context handle elsewhere

context.deleteDatabase("mydata.db");


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消