我目前正在使用Cursor在我的Android应用中列出SD卡上的所有图像。但是,我希望光标在创建图像之后对图像进行排序,目前情况并非如此。
有谁知道我应该做什么?
谢谢!
public ArrayList<String> getFilePaths() {
Uri uri;
ArrayList<String> listOfAllImages = new ArrayList<String>();
Cursor cursor;
int column_index_data, column_index_folder_name;
String PathOfImage = null;
uri = android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
String[] projection = { MediaStore.MediaColumns.DATA,
MediaStore.Images.Media.BUCKET_DISPLAY_NAME };
cursor = Touch.getTouchContext().getContentResolver().query(uri, projection, null,
null, null);
column_index_data = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
column_index_folder_name = cursor
.getColumnIndexOrThrow(MediaStore.Images.Media.BUCKET_DISPLAY_NAME);
ArrayList<String> filePaths = new ArrayList<String>();
while (cursor.moveToNext()) {
PathOfImage = cursor.getString(column_index_data);
//listOfAllImages.add(PathOfImage);
filePaths.add(PathOfImage);
}
答案 0 :(得分:0)
在查询中添加了选择:
org.springframework.orm.ObjectOptimisticLockingFailureException: Object of class [nl.coin.comp.domain.ServiceProvider] with identifier [105]: optimistic locking failed; nested exception is org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) : [nl.coin.comp.domain.ServiceProvider#105]
更改了光标添加文件的方式:
cursor = Touch.getTouchContext().getContentResolver().query(uri, projection, null, null, MediaStore.Images.Media.DATE_ADDED);