Search code examples
javaandroidsqliteview

Can I use an SQLite View as parameter to a rawQuery


I'm attempting to add a few reports to my Android app. First, I defined them as Views in my SQLite database to make sure they work correctly. Here's one of them:

CREATE VIEW r3_DNFs AS SELECT Epreuve, Dossard, STRFTIME('%H:%M:%S %d',TempsPassage) AS "Temps" FROM Coureurs WHERE Statut is "DNF" ORDER BY SUBSTR(Epreuve, 5) + 0 DESC, Dossard;

Can I use the following to simplify my coding?

Cursor c = db.rawQuery("SELECT Epreuve, Dossard, Temps FROM r3_DNFs",null);

Solution

  • With rawQuery you can use any valid sqlite's statement but it should not be terminated (which doesn't contain the ; symbol).