外部的 MediaStore URI?
作为 MediaStore 新手,我不知道这个 uri 有什么问题:
MediaStore.Files.getContentUri("external")
这些 uri 不断返回零。
我的示例代码:
String file = null;
String sortBy = "";
if (filterSort == "time") {
sortBy = MediaStore.Files.FileColumns.DATE_MODIFIED;
} else if (filterSort == "size") {
sortBy = MediaStore.Files.FileColumns.SIZE;
}
String[] projection = {MediaStore.Files.FileColumns.DATA};
android.database.Cursor cursor = getContentResolver().query(MediaStore.Files.getContentUri("external"), projection, null, null, sortBy + "DESC");
if (cursor != null) {
while (cursor.moveToNext()) {
file = cursor.getString(0);
states.add(file);
}
cursor.close();
}
尝试解决 Uri.parse
有效,但没有应用排序过滤器。回来与 MediaStore.Files.getContentUri("external")
,它不断通过 Android 8.1 设备上的异常向我提供此信息:
android.database.sqlite.SQLiteException:
no such column: date_modifiedDESC (code 1): , while compiling: SELECT _data FROM files WHERE ( invalid=0) ORDER BY date_modifiedDESC
是否有任何方法来解决/更改/执行?
As a MediaStore newbie's, I dunno what's wrong with this uri:
MediaStore.Files.getContentUri("external")
Those uri's keeps returns to zero.
My example codes:
String file = null;
String sortBy = "";
if (filterSort == "time") {
sortBy = MediaStore.Files.FileColumns.DATE_MODIFIED;
} else if (filterSort == "size") {
sortBy = MediaStore.Files.FileColumns.SIZE;
}
String[] projection = {MediaStore.Files.FileColumns.DATA};
android.database.Cursor cursor = getContentResolver().query(MediaStore.Files.getContentUri("external"), projection, null, null, sortBy + "DESC");
if (cursor != null) {
while (cursor.moveToNext()) {
file = cursor.getString(0);
states.add(file);
}
cursor.close();
}
Trying to solve withUri.parse
worked but did not apply sorting filter's. Back withMediaStore.Files.getContentUri("external")
, it keeps giving me this via Exception on Android 8.1 devices:
android.database.sqlite.SQLiteException:
no such column: date_modifiedDESC (code 1): , while compiling: SELECT _data FROM files WHERE ( invalid=0) ORDER BY date_modifiedDESC
Is there any way to solve/change/do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也不知道 blackapps 指的是什么,因为他没有以任何方式解决这个问题。
有很多 uri,具体取决于您要提取的内容。
例如:
或对于艺术家;
“date_modifiedDESC”部分是导致问题的原因,因为它需要空格“date_modified DESC”
我建议您修改您的投影,例如
而不是
MediaStore.Files.FileColumns.DATE_MODIFIED;
Nor sure what blackapps is referring to as he does not address the question in any way.
There are a number of uris, depending what you want to extract.
for example:
or for artists;
the part "date_modifiedDESC" is what causes the issue as it requires a space "date_modified DESC"
I suggest you amend your projection, for example
instead of
MediaStore.Files.FileColumns.DATE_MODIFIED;