Android 在 SQLiteDatabase.query() 中使用 String[] selectionArgs
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10507005/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using String[] selectionArgs in SQLiteDatabase.query()
提问by BenjiWiebe
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?
我如何使用String[] selectionArgs
in SQLiteDatabase.query()
?我希望我可以将它设置为null
,因为我没有用它。我只是想将整个未排序的表从数据库加载到Cursor
. 关于如何实现这一目标的任何建议?
回答by Gal Ben-Haim
selectionArgs replace any question marks in the selection string.
selectionArgs 替换选择字符串中的任何问号。
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
至于你的问题 - 你可以使用 null
回答by waqaslam
Yes, you may set all parameters to nullexcept the table name.
是的,您可以将除表名之外的所有参数设置为空。
for example:
例如:
Cursor cursor = db.query("TABLE_NAME", null, null, null, null, null, null);