I have a very simple situation:
I have a table about 5 thousand rows in size:
CREATE TABLE "words" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , "name" TEXT NOT NULL , "def" TEXT NOT NULL, "rand" INTEGER)
What I update periodically using "UPDATE words SET rand = random ()"
In android, when I create a cursor using rawQuery () using the following:
SELECT w.id, w.name, w.def, w.rand FROM words w ORDER BY w.rand ASC;
The returned cursor does not iterate in the correct order. For example. it will output columns with rand values ββin the following order:
-1298882092 -2138143484 -1115732861 118839193 ...
Does anyone know what is going on here? Doesn't that work? If I run the same query in SQLiteManager, it will return the results in the correct order, so this seems to be specific to android / cursor.
UPDATE:
Here is the code in android, I tried several ways:
Attempt 1:
Cursor cursor = db.rawQuery("SELECT w.id, w.name, w.def, w.rand FROM words w ORDER BY w.rand ASC", new String[]{});
Attempt 2:
Cursor cursor = db.query("words", new String[]{"id", "name", "def", "rand"}, null, null, null, null, "rand ASC");
In both cases, I repeat the following:
while(cursor.moveToNext()) { ... Log.i("Test", cursor.getInt(3)); ... }