Using String[] selectionArgs in SQLiteDatabase.query()

馋奶兔 提交于 2019-11-27 00:51:00

问题


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?


回答1:


selectionArgs replace any question marks in the selection string.

for example:

String[] args = { "first string", "second@string.com" };
Cursor cursor = db.query("TABLE_NAME", null, "name=? AND email=?", args, null);

as for your question - you can use null




回答2:


Yes, you may set all parameters to null except the table name.

for example:

Cursor cursor = db.query("TABLE_NAME", null, null, null, null, null, null);


来源:https://stackoverflow.com/questions/10507005/using-string-selectionargs-in-sqlitedatabase-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!