我想从图库中挑选图像并将其复制到其他文件夹在SD卡。
code来选择图片从GALLARY
意图photoPickerIntent =新的意图(Intent.ACTION_PICK);
photoPickerIntent.setType(图像/ *);
startActivityForResult(photoPickerIntent,REQUEST_ code_CHOOSE_PICTURE_FROM_GALLARY);
我得到内容://媒体/外部/图片/媒体/ 681
此URI onActivityResult
我要复制的图像,
表格路径=内容://媒体/外部/图片/媒体/ 681
要路径=文件:/// MNT / SD卡/ sharedresources /
SD卡在Android的这条道路
如何做到这一点?
解决方案 的OutputStream出来;
串根= Environment.getExternalStorageDirectory()getAbsolutePath()+/。
文件createDir =新的文件(根+文件夹名称+文件分割符);
如果(!createDir.exists()){
createDir.mkdir();
}
档案文件=新的文件(根+文件名,文件夹名称+文件分割符+);
file.createNewFile();
OUT =新的FileOutputStream(文件);
out.write(数据);
out.close();
希望这将有助于U
i want to pick image from Gallery in and copy it in to other Folder in SDCard.
Code to Pick Image from Gallary
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, REQUEST_CODE_CHOOSE_PICTURE_FROM_GALLARY);
i get content://media/external/images/media/681
this URI onActivityResult.
i want to copy the image,
Form path ="content://media/external/images/media/681
To path = "file:///mnt/sdcard/sharedresources/
this path of sdcard in Android.
how to do this ?
解决方案OutputStream out;
String root = Environment.getExternalStorageDirectory().getAbsolutePath()+"/";
File createDir = new File(root+"Folder Name"+File.separator);
if(!createDir.exists()) {
createDir.mkdir();
}
File file = new File(root + "Folder Name" + File.separator +"Name of File");
file.createNewFile();
out = new FileOutputStream(file);
out.write(data);
out.close();
Hope it will help u