开发者

how to delete the database in Android?

I need to delete the database fil开发者_Go百科e.Here is my code to delete the file.

String strDBFilePath="/data/data/snow.AppStore/databases/"+strAppDBName;
File file = new   File(strDBFilePath);
file.delete();

But it i can't delete the DB file.How to delete DB ????


A couple of questions.

  1. You are the developer of the snow App, or is it just an app for which you want to remove the database? If it's the latter you can do a 'clear data' in the 'manage applications' menu in the Android settings.
  2. Presuming you are the developer, why do you want to remove the database? For development purposes? If so you can connect your (virtual) device and remove the database via a file explorer? See the section on the file explorer in this article
  3. Why do you want to do it programmatically? Will it be a recurring task? You can also try the deleteDatabase method defined on the Context class

Good luck!

Johan


You can only delete your own database file. Also I do not believe dots in the folder names are allowed and you do not need to do that since it gets deleted automatically when the app is deleted. Whats your use case?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜