随机()的源码和Android SDK [英] Random() in sqlite and Android sdk
本文介绍了随机()的源码和Android SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从Android的应用程序SQLite数据库随机抽取行。我知道的是,使用SQLite,您可以选择任意行,
I want to extract random rows from the app sqlite database in Android. I'm aware that, with sqlite, you can select random rows with:
SELECT * FROM table ORDER BY RANDOM() LIMIT 1;
在应用程序中,我有这样的事情
In the app, I have something like this
return mDb.query(TABLE, new String[] {"col1", "col2"}, null, null, null, null, "Random()", "2");
这是在表表中抽取两个随机行。但它一直返回相同的行。什么是错机智的声明?
this is for extract two random rows in table TABLE. But it keeps returning the same rows. What's wrong wit the statement?
感谢
推荐答案
试试这个
Cursor cursor = this.db.query("YourTable Order BY RANDOM() LIMIT 1",
new String[] { "*" }, null, null, null, null, null);
这篇关于随机()的源码和Android SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文