如何在Android中使用光标删除数据?



我有一个Android数据库。我用游标

从数据库中读取数据
Cursor c = sqLiteDatabase.query(SmartProbeDBOpenHelper.TABLE_NAME, SmartProbeDBOpenHelper.columns, null, new String[]{}, null, null, null);

现在我想删除数据,我用游标读取。这意味着我用光标读取的内容。

注意:我有两个后台服务与AsyncTask。一个服务写入数据库,另一个服务读取和删除行。

我该怎么做??

删除某些行

String whereClauseWithoutTheWhere = "_id = ?";
String[] params =new String[]{100,151};
boolean succeeded = sqLiteDatabase.delete(SmartProbeDBOpenHelper.TABLE_NAME,whereClauseWithoutTheWhere,params)>0;

要删除所有行,您的whereClause需要为null

最新更新