How do I use the String[] selectionArgs in SQLiteDatabase.query()? I wish I could just set it to null, as I have no use for it. I am just trying to load an entire unsorted table from a database into a Cursor. Any suggestions on how to achieve this?
-
1You can set them to null. Show your code.Snicolas– Snicolas2012-05-08 21:46:46 +00:00Commented May 8, 2012 at 21:46
-
11Sometimes, the first step is to actually try something.dymmeh– dymmeh2012-05-08 21:48:21 +00:00Commented May 8, 2012 at 21:48
Add a comment
|
2 Answers
selectionArgs replace any question marks in the selection string.
for example:
String[] args = { "first string", "[email protected]" };
Cursor cursor = db.query("TABLE_NAME", null, "name=? AND email=?", args, null);
as for your question - you can use null
3 Comments
Axel
Thanks this worked for me. @GalBen-Haim please do you think you could give me your opinion on this question stackoverflow.com/questions/25598696/…
karl
Note that passing null to
columns is discouraged. You should explicitly query only the columns you need. developer.android.com/reference/android/database/sqlite/…Rohit Singh
So how does it replaces ? with selection Args. Is it like first ? will be replaced by args[0]. If so what happens when there is mismatch in the num of ? and items in args[] ? . Please explain