I have string array with columns I want to select:
String[] columns = {"col1", "col2", "col3"};
The columns might change in the future, but will always be a subset of available columns.
I cannot find a SQLiteDatabase API that lets me pass this array as columns. The only solution I have so far is to just string join the columns with , as separator and add it into my query string and perform a rawQuery.
Is there a better solution?
EDIT
The query is a JOIN query.
querymethod fromSQLiteQueryBuilderit has aprojectionparameter. String: A list of which columns to return. Passing null will return all columns, which is discouraged to prevent reading data from storage that isn't going to be used.SQLiteQueryBuildercan performJOINs. I will look into it.