Reputation: 603
i have this selection query to fetch rows from the sqlite database of android phone contacts.
String selection = ContactsContract.Data.MIMETYPE + " = '" + ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE + "'"
+ " AND "+ContactsContract.Data.DATA10+ " = '" + select + "'";
Log.d(LOG_TAG,"selection in update data"+selection);
c = mContext.getContentResolver().query(CONTENT_URI, Projection,selection, null, null);
where select = +12244004242
I am successfully able to fetch the reqd data. However my requirement is if i have more than one string. i.e an array of strings.how do i write the query?
I was tring with
String selection = ContactsContract.Data.DATA10 IN ("+select+")";
where select = +12244004242,+12244004245,+12244004248
however i am not getting any values.please help me write the selection query.
Upvotes: 0
Views: 110
Reputation: 2658
You could try using transaction queries, this is how i went about extracting data from my sqlite database, something like:
db = window.openDatabase("DBID", "1.0", "DBName", 50000000);
db.transaction(TableName, errorCB, successCB);
tx.executeSql('SELECT Col1, Col2 FROM TableName WHERE Col1="'+ test +'";', [], querySuccess, errorCB);
function querySuccess(tx, result)
{
// DO SOMETHING HERE
}
function errorCB(tx, err) {
alert("Error processing SQL: "+err.message);
}
Upvotes: 0
Reputation: 25793
Try to use IN(" + select + ")
with select = "'+12244004242','+12244004245','+12244004248'"
Upvotes: 1
Reputation: 5266
You can do a nested OR:
so:
select = +12244004242 OR select=+12244004245 OR select=+12244004248
Upvotes: 0