В моем приложении для Android я хочу скопировать медиа-изображения в другую папку (в моем коде ниже я пытаюсь скопировать изображение из "/mnt/sdcard/DCIM/Camera/my_photo.jpg" в "/ mnt / sdcard / PortFolio")/ MyGallery /. Я пробовал это с помощью следующего кода, но он не работает. Кто-то мне в этом помогает ??? Есть ли другой способ? ??
File sd = Environment.getExternalStorageDirectory();
File data = Environment.getDataDirectory();
if (sd.canWrite()) {
String sourceImagePath= "/mnt/sdcard/DCIM/Camera/my_photo.jpg";
String destinationImagePath= "/mnt/sdcard/PortFolio/MyGallery/";
Log.d("destinationImagePath", ""+destinationImagePath);
File source= new File(data, sourceImagePath);
File destination= new File(sd, destinationImagePath);
Log.d("before copying", "");
if (source.exists()) {
FileChannel src = new FileInputStream(source).getChannel();
FileChannel dst = new FileOutputStream(destination).getChannel();
dst.transferFrom(src, 0, src.size());
src.close();
dst.close();
}