【发布时间】:2018-10-06 15:45:33
【问题描述】:
我将我的应用程序设计为将登录数据保存在 SQLite 数据库中,但我想在用户从应用程序注销时删除孔表和数据
【问题讨论】:
标签: java android database sqlite
我将我的应用程序设计为将登录数据保存在 SQLite 数据库中,但我想在用户从应用程序注销时删除孔表和数据
【问题讨论】:
标签: java android database sqlite
使用 DROP TABLE:
// query to obtain the names of all tables in your database
Cursor c = db.rawQuery("SELECT name FROM sqlite_master WHERE type='table'", null);
List<String> tables = new ArrayList<>();
// iterate over the result set, adding every table name to a list
while (c.moveToNext()) {
tables.add(c.getString(0));
}
// call DROP TABLE on every table name
for (String table : tables) {
String dropQuery = "DROP TABLE IF EXISTS " + table;
db.execSQL(dropQuery);
}
希望对你有帮助
【讨论】: