I am fetching all albums of images using MediaStore and it was working fine before Android Q. But today I increased my compile version to 29 and it is throwing this exception :
android.database.sqlite.SQLiteException: near "GROUP": syntax error (code 1 SQLITE_ERROR): , while compiling: SELECT bucket_id, bucket_display_name, mime_type FROM images WHERE ((is_pending=0) AND (is_trashed=0) AND (volume_name IN ( 'external_primary' ))) AND ( GROUP BY bucket_id )
Here is my code to query MediaStore :
String[] PROJECTION_BUCKET = {
MediaStore.Images.ImageColumns.BUCKET_ID,
MediaStore.Images.ImageColumns.BUCKET_DISPLAY_NAME,
MediaStore.Images.ImageColumns.MIME_TYPE};
String BUCKET_GROUP_BY = "1) GROUP BY 1,(2";
String BUCKET_ORDER_BY = "MAX(datetaken) DESC";
Cursor cur = context.getContentResolver().query(getUriOfType(type),
PROJECTION_BUCKET,
BUCKET_GROUP_BY,
null,
BUCKET_ORDER_BY);
As Group is not working in Android Q
.
Any solution for this?