Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Q SQLiteException #154

Open
breewf opened this issue Apr 23, 2019 · 6 comments
Open

Android Q SQLiteException #154

breewf opened this issue Apr 23, 2019 · 6 comments

Comments

@breewf
Copy link

breewf commented Apr 23, 2019

设备:Google Pixel XL

系统版本:Android Q

执行AlbumTask.buildAlbumInfo时异常:

android.database.sqlite.SQLiteException: near "GROUP": syntax error (code 1 SQLITE_ERROR): , while compiling: SELECT bucket_id, bucket_display_name FROM images WHERE ((is_pending=0) AND (is_trashed=0)) AND ((0==0) GROUP BY(bucket_id)) ORDER BY date_modified desc
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:184)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:423)
at android.content.ContentResolver.query(ContentResolver.java:862)
at android.content.ContentResolver.query(ContentResolver.java:809)
at android.content.ContentResolver.query(ContentResolver.java:767)
at com.bilibili.boxing.model.task.impl.AlbumTask.buildAlbumInfo(AlbumTask.java:72)
at com.bilibili.boxing.model.task.impl.AlbumTask.start(AlbumTask.java:64)
at com.bilibili.boxing.model.BoxingManager$2.run(BoxingManager.java:74)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:914)

@pinguo-sunjianfei
Copy link

我也遇到这个问题了。

@pinguo-sunjianfei
Copy link

好久可以更新呢?

@zhoufeng1213
Copy link

只能把代码下下来之后改了
bucketCursor = cr.query(Media.EXTERNAL_CONTENT_URI, distinctBucketColumns, "0==0) "+" GROUP BY(" + Media.BUCKET_ID, null,
Media.DATE_MODIFIED + " desc");
把上面的代码替换成下面的:
bucketCursor = cr.query(Media.EXTERNAL_CONTENT_URI, distinctBucketColumns, null, null,
Media.DATE_MODIFIED + " desc");
//android Q之后查询的where条件会出现(())两层的括号,没法使用group by
//由于查出来的数据中有多个buckId和name重复的数据,需要把它过滤掉
HashSet<HashMap<String,String>> hashSet = new HashSet<>();
if (bucketCursor != null && bucketCursor.moveToFirst()) {
do {
String buckId = bucketCursor.getString(bucketCursor.getColumnIndex(Media.BUCKET_ID));
String name = bucketCursor.getString(bucketCursor.getColumnIndex(Media.BUCKET_DISPLAY_NAME));
if (!TextUtils.isEmpty(buckId)) {
HashMap<String,String> map = new HashMap<>(2);
map.put("buckId",buckId);
map.put("name",name);
hashSet.add(map);
}
} while (bucketCursor.moveToNext());
}
for(HashMap<String,String> map:hashSet){
AlbumEntity album = buildAlbumInfo(map.get("name"), map.get("buckId"));
if (!TextUtils.isEmpty(map.get("buckId"))) {
buildAlbumCover(cr, map.get("buckId"), album);
}
}

@li-lance
Copy link

@ChenSiLiang 有空适配下吗?

@Mysqi
Copy link

Mysqi commented Jul 3, 2019

有更新么?1.0.4版本还是有这个问题

@parcool
Copy link

parcool commented Sep 12, 2019

同。等更新。。。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants