【发布时间】:2011-12-11 12:34:39
【问题描述】:
我有 student 表,它有四个字段 id、name、address 和 age。在这个表 50 学生。我的问题是,如何改组 id 并获取该 id 的详细信息(id、姓名、地址和年龄)并一次获取一个 id,如果我单击 next 按钮然后是下一个学生详细信息。
DatabaseHeper.java
// I donot understand which code write in DatabaseHeper.java file
/*
public Cursor shuffleJokes(int [] id) {
Cursor c = null;
c = myDataBase.rawQuery("select _id,title,body from jokes where title ="
+ id, null);
return c;
}*/
public void shuffleJokes(int [] ar) {
Random rnd = new Random();
for (int i = ar.length - 1; i >= 0; i--)
{
int index = rnd.nextInt(i + 1);
// Simple swap
int a = ar[index];
ar[index] = ar[i];
ar[i] = a;
}
shuffleStudnt.java
DatabaseHelper db;
Cursor cur
cur=db.shuffleArray(arrayofid); // how to get arrayofid array which is id of student table
cur.moveToFirst();
我有问题,如何在数组中获取表 ID。请给我写在 DatabaseHeper.java 和 shuffleStudent.java 文件中的代码的最佳解决方案。
【问题讨论】: