1
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

I am trying to copy .jpg file to and from in Storage folders.

  try {
        Process c = Runtime.getRuntime().exec("dd if="+path+ 
        "of="+Environment.getExternalStorageDirectory()+"/1.jpg");
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

path contains the exact image location in storage ! But it doesn't work. It can't copy the image to another folder of storage. Please kindly help me to solve this in every possible way! Thank you.

Su Su Aye
  • 13
  • 3

2 Answers2

0

It happens to me sometimes and I use

Environment.getExternalStorageDirectory().getPath()

Have you tried that?

loopidio
  • 423
  • 1
  • 5
  • 11
  • please let me know Is there any other way to copy files in storage ? – Su Su Aye Jan 13 '15 at 15:42
  • Have you tried previous answers? Here it has good answers: http://stackoverflow.com/questions/4178168/how-to-programmatically-move-copy-and-delete-files-and-directories-on-sd – loopidio Jan 13 '15 at 15:45
  • Thank you so much for reference ! now trying to accept it :) . Thanks ! – Su Su Aye Jan 13 '15 at 15:49
0
    try {
        String cmd="dd if="+path+" of="+Environment.getExternalStorageDirectory()+"/1.jpg";
        Runtime.getRuntime().exec(cmd+"\n");

    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }