【发布时间】:2014-04-03 06:18:09
【问题描述】:
假设我有四到五张图片,无论是来自相机还是画廊,我所做的那部分。现在 我想让那四五张图片出现在另一个活动中,我该怎么做, 就像您在 olx 应用程序中看到的那样。 谁能帮我解决这个问题。
下面是我的代码:-
Uri selectedImage = data.getData();
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(selectedImage,filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
cursor.close();
SharedPreferences sp = getSharedPreferences("ImageSharedPref", 0); // Open SharedPreferences with name AppSharedPref
Editor editor = sp.edit();
editor.putString("picturePath", picturePath); // Store selectedImagePath with key "ImagePath". This key will be then used to retrieve data.
editor.commit();
【问题讨论】:
-
只需保存在应用程序类中,然后从其他活动中使用它..
-
最好保存在文件中,并将路径发送到下一个Activity。
-
对这类工作使用 Singleton 类
-
我没有得到 BhanuSharma 怎么办
-
正如你在 olx 中看到的,就像我必须做的那样
标签: android image android-camera sharedpreferences image-gallery