Android SQLite Query and using a cursor to handle multiple rows

I have a query, (I am using rawQuery() )

  SELECT * FROM <table> 

Then I save what it returns using the cursor. From what I want to do, start with the first line, so .. cursor.moveToFirst() then take each column, column by column and store its specific value in a variable. Then I want to go to the next line and do the same. So, I think, my question is: how do I get the cursor to process multiple columns?

Thanks,

+4
source share
1 answer

I might be missing something if you don't have a nested loop.

The outer loop cycles through each entry:

 while (cursor.moveToNext()) { ... // inner loop here ... } 

and the inner loop will cycle through each column

 for (i=0; i<cursor.getColumnCount(); i++) { ... String var1 = cursor.getString(i); ... } 
+14
source

Source: https://habr.com/ru/post/1313762/


All Articles