如何在sqlite中删除数据库?

Raj*_*rma 29 sqlite android

我在android中使用SQLite.我想删除数据库.

例如: mysql- drop database dbname

如何在SQLite中实现此代码?

the*_*sic 57

删除你的应用数据库试试这个:

 this.deleteDatabase("databasename.db");
Run Code Online (Sandbox Code Playgroud)

这将删除数据库文件

  • 您必须有权访问上下文才能执行此操作. (4认同)

ype*_*eᵀᴹ 33

创建或删除数据库的概念对于像SQLite这样的嵌入式数据库引擎没有意义.它只对客户端 - 服务器数据库系统有意义,例如MySQL或Postgres使用的系统.

要创建新数据库,只需执行sqlite_open()命令行或从命令行执行sqlite3 databasefilename.

要删除数据库,请删除该文件.

参考:sqlite - 不支持的SQL


Chr*_*ris 7

您可以tables像通常那样通过发出SQL命令来删除.如果要删除整个数据库,则必须删除该文件.您可以删除位于下方的文件

data/data/com.your.app.name/database/[databasefilename]

你可以从名为"FileBrowser"的eclipse视图中取出"Android"类别.或直接在您的模拟器或手机上.


stu*_*rtd 5

来自http://www.sqlite.org/cvstrac/wiki?p=UnsupportedSql

要创建一个新数据库,只需执行 sqlite_open()。要删除数据库,请删除该文件。


Can*_*ner 5

如果要以编程方式删除数据库,可以deleteDatabaseContext类中使用:

deleteDatabase(String name)
删除与此Context的应用程序包关联的现有私有SQLiteDatabase.


boi*_*ter 5

SQLite database FAQ: How do I drop a SQLite database?

People used to working with other databases are used to having a "drop database" command, but in SQLite there is no similar command. The reason? In SQLite there is no "database server" -- SQLite is an embedded database, and your database is entirely contained in one file. So there is no need for a SQLite drop database command.

To "drop" a SQLite database, all you have to do is delete the SQLite database file you were accessing.
Run Code Online (Sandbox Code Playgroud)

http://alvinalexander.com/android/sqlite-drop-database-how复制