gpt4 book ai didi

java - 从两个不同的数据源中选择排序的数据

转载 作者:行者123 更新时间:2023-12-01 05:34:28 25 4
gpt4 key购买 nike

我需要最新的图像,并且我需要从两个不同的位置进行选择。我该怎么做?

下面是我的代码,它仅从 /dcim/camera 返回,而不是从 eye-fi 返回,而它应该能够从两者返回。

private void PopulateDataSource() {
if (_context == null) return;

if(_context.getContentResolver() != null) {
final ContentResolver cr = _context.getContentResolver();

String[] projections = new String[] {
MediaStore.Images.ImageColumns._ID,
MediaStore.Images.ImageColumns.DATE_TAKEN,
MediaStore.Images.ImageColumns.DATA };
String sortOrder = String.format(
"%s limit 10", Images.ImageColumns.DATE_TAKEN + " DESC");

final String[] selectionArgs = {
getBucketId(Environment.getExternalStorageDirectory().toString() +
"/Eye-Fi"),
getBucketId(Environment.getExternalStorageDirectory().toString() +
"/DCIM/Camera") };

final String selection = MediaStore.Images.Media.BUCKET_ID + " = ?";

try {
// select all images from DataBase and set it in Cursor
SearchCursor = cr.query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
projections, selection, selectionArgs, sortOrder);

}
catch (Exception ex) {
Log.e("Cursor failed", ex.getMessage());
}
}
}

最佳答案

将您的选择字符串替换为以下内容:

final String selection = MediaStore.Images.Media.BUCKET_ID + " IN (?, ?)";

关于java - 从两个不同的数据源中选择排序的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8401008/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com