由网友(孤檠)分享简介:我想提出一个应用程序,当用户点击一个按钮,SQLite数据库被清除。这是我到目前为止已经试过:I would like to make an app where the user clicks a button, and the SQLite database is cleared. Here's what I've...
我想提出一个应用程序,当用户点击一个按钮,SQLite数据库被清除。这是我到目前为止已经试过:
I would like to make an app where the user clicks a button, and the SQLite database is cleared. Here's what I've tried so far:
db.delete(TABLE_NAME, null, null);
我是什么做错了吗?
What am I doing wrong?
推荐答案
您delete()的调用是正确的。难道你写的数据库?下面是例如使用删除方法:
Your delete() call is correct. Did you get writable database? Here is example of method using delete:
/**
* Remove all users and groups from database.
*/
public void removeAll()
{
// db.delete(String tableName, String whereClause, String[] whereArgs);
// If whereClause is null, it will delete all rows.
SQLiteDatabase db = helper.getWritableDatabase(); // helper is object extends SQLiteOpenHelper
db.delete(DatabaseHelper.TAB_USERS, null, null);
db.delete(DatabaseHelper.TAB_USERS_GROUP, null, null);
}
相关推荐
最新文章