Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sqlite Delete Query syntax in Android

Tags:

android

sqlite

I want to write a Query to delete a row from the table. I am confused of writing the statement. I need some help in writing this. I am providing my requirement here with plain sql statement.

(Pseudo code)

delete from tablename where value =="string1" && value2 == "string2" && value3 == "string3";

I want to write this in the Sqlite syntax for android db.delete(tablename, whereclause, whereargs);.

I would be thankful for your help.

like image 710
Balakrishna Avatar asked Nov 04 '10 09:11

Balakrishna


2 Answers

a better way would be to use

String where = "value1 = ?"
+ " AND value2 = ?"
+ " AND value3 = ?";
String[] whereArgs = {string1,string2,string3};
like image 68
Dany Y Avatar answered Oct 06 '22 22:10

Dany Y


String table_name = "myTable";
String where = "value1 = 'string1'"
    + " AND value2 = 'string2'"
    + " AND value3 = 'string3'";
String whereArgs = null;
mDb.delete(table_name, where, whereArgs);
like image 40
user479211 Avatar answered Oct 06 '22 22:10

user479211