Batch Delete items with Content Provider in Android

后端 未结 3 1767
长发绾君心
长发绾君心 2021-01-04 19:40

I\'m trying to batch delete some items in a table.

    String ids = { \"1\", \"2\", \"3\" };

    mContentResolver.delete(uri, MyTables._ID + \"=?\", ids);
<         


        
3条回答
  •  被撕碎了的回忆
    2021-01-04 20:33

    String sqlCommand = String.format("DELETE FROM %s WHERE %s IN (%s);", TABLE_NAME, KEY_ID, 1,2,3);
    
    db.execSQL(sqlCommand);
    

提交回复
热议问题