2

I'm new in android developer ,I'm a programmer Delphi and Lazarus, I have a program using SQLite Database and I'm trying to get the same program in android, but I have many questions.

I need a method to return an result of an select like:

SELECT * from tmc_configuracao ORDER BY cod_configuracao DESC 

After that i will send this result to a scrollingtable" I have no idea how to do this.

Anyone can help me with the code?

0

1 Answer 1

6
String query="SELECT * from tmc_configuracao ORDER BY cod_configuracao DESC";
Cursor cursor=(instance of SQLiteDatabase).rawQuery(query);
while (cursor.moveToNext()) {
  String result_0=cursor.getString(0);
  String result_1=cursor.getString(1);
  //and so on
}
cursor.close();
(instance of SQLiteDatabase).close();
Sign up to request clarification or add additional context in comments.

2 Comments

rawQuery() takes at least 2 parameters: developer.android.com/reference/android/database/sqlite/…
You can replace the second parameter with null if you do not want to have any selectionArgs. Cursor testCursor = sqLiteDatabase.rawQuery(sqlQuery, null);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.