如何从Android的编程方式删除SQLite数据库

问题描述:

我想删除的 Android的文件系统编程数据库文件?我能有一个shell脚本启动亚洲开发银行这反过来运行shell脚本在Android的空间做数据库删除?我可以得到这个从做中的的JUnit 测试案例(以系统()调用)?

I would like to delete the database file from the Android file system programatically? Can I have a shell script launch adb which in turns runs a shell script in the Android space to do the database deletion? Can I get this done from within a JUnit test case (with a system() call)?

如何删除在Android的整个数据库?我需要使整个事情走开,所以我可以测试数据库的创建。我可以删除表,但是这还不够。这是在模拟器,而不是在手机上。

How do I delete an entire database in Android? I need to make the whole thing go away so I can test database creation. I can drop tables, but that's not enough. This is in the emulator, not on a phone.

一旦你有你的背景,知道数据库的名称,用途:

Once you have your Context and know the name of the database, use:

context.deleteDatabase(DATABASE_NAME);

在这一行总是会自动运行,数据库应予以删除。

When this line gets run, the database should be deleted.