我是用下面代码得到相册图片路径的,但是有个缺点,就是只能得到指定文夹中的图片路径
/**
* 得到指定文夹中所有图片的路径
**/
private String[] ListFile() {
File file = new File(Environment.getExternalStorageDirectory()
+ "/DCIM/Camera/");
File[] f = file.listFiles();
int count = f.length;
String[] Path = new String[f.length];
for (int i = 0; i < f.length; i++) {
Path[i] = f[i].getPath();
}
String[] inverted_orderPath = new String[f.length];// 倒序路径
for (int i = 0; i < f.length; i++) {// 倒序排列
inverted_orderPath[i] = Path[--count];
}
return inverted_orderPath;
}
/**
* 得到指定文夹中所有图片的路径
**/
private String[] ListFile() {
File file = new File(Environment.getExternalStorageDirectory()
+ "/DCIM/Camera/");
File[] f = file.listFiles();
int count = f.length;
String[] Path = new String[f.length];
for (int i = 0; i < f.length; i++) {
Path[i] = f[i].getPath();
}
String[] inverted_orderPath = new String[f.length];// 倒序路径
for (int i = 0; i < f.length; i++) {// 倒序排列
inverted_orderPath[i] = Path[--count];
}
return inverted_orderPath;
}
uri = Uri.parse(MediaStore.Images.Media.insertImage(
getContentResolver(), bitmap, null, null));
String[] projection = { MediaStore.Images.Media.DATA };
Cursor actualimagecursor = managedQuery(uri, projection, null,
null, null); int actual_image_column_index = actualimagecursor
.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
actualimagecursor.moveToFirst();
// 获取文件路径,方便上传文件等
img_path = actualimagecursor.getString(actual_image_column_index);