I need the most updated image, and I need to select from two different places. How do I do this?
Below is my code, and it returns only from /dcim/camera, not from eye-fi when it should be able to return from both.
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());
}
}
}
Replace your selection string with the following: