private int updDel ( int op , Uri uri , ContentValues vals , String sel , String [ ] args ) { /* get the IDs of records that will be affected */ Sql sql = elements ( op , uri , new String [ ] { "rowid" } , sel , args , null ) ; long [ ] ids = Cursors . allLongs ( sql . mResult ) ; /* update or delete the records and then notify about any changes */ SQLiteDatabase db = mHelper . getWritableDatabase ( ) ; int rows = op == UPDATE ? db . update ( sql . table ( ) , vals , sql . sel ( ) , sql . args ( ) ) : db . delete ( sql . table ( ) , ! TextUtils . isEmpty ( sql . sel ( ) ) ? sql . sel ( ) : "1" , sql . args ( ) ) ; if ( rows > 0 ) { for ( long id : ids ) { notifyChange ( ContentUris . withAppendedId ( sql . notifyUri ( ) , id ) , uri ) ; } } return rows ; }
Update or delete records and get the number of rows affected .