0

I would like to copy the files (image files captured from the camera app) between internal storage, from /data/data/[my app]/photo to another folder within the internal storage.

As you can see in the screen shot below, I have successfully changed the permission of both directories into '777' via the below code:

Runtime.getRuntime().exec("su");  
Runtime.getRuntime().exec("chmod 777 /data/data/[my app]/photo", null, new File("/data/data/[my app]/photo"));

So, I use the similar code to change the permission for the files in the "photo" folder but nothing happens.

Runtime.getRuntime().exec("su");  
Runtime.getRuntime().exec("chmod 777 /data/data/[my app]/photo/2_20130406_143344");

It would be very grateful if someone give me some direction as it has bothered me for the entire weekend.

Thanks a lot in advance!

enter image description here

Raghav Sood
  • 81,899
  • 22
  • 187
  • 195
kwytse
  • 113
  • 2
  • 15
  • The camera app does not store in /data/data/... You do not have to mess around with linux type permissions just to copy some files. – greenapps Apr 07 '13 at 18:14

1 Answers1

0

If you are copying from one internal location to another and created by your app, you do not need additional permission. Try following

ContextWrapper wrapper = new ContextWrapper(context);
File sourceDirectory = wrapper.getDir(SOURCE_FOLDER_NAME, Context.MODE_PRIVATE);
File destinationDirectory = wrapper.getDir(DESTINATION_FOLDER_NAME, Context.MODE_PRIVATE);

Now use a recursive function to copy from source to destination

private boolean copyFiles(sourceDirectory, desitnationDirectory); 

For, how to copy files recursively this.

Camera Images are stored on SD card and, you can always directly access those anytime.

Community
  • 1
  • 1
minhaz
  • 4,233
  • 3
  • 33
  • 49
  • sorry for late reply as I was sick in the past few days. I tried to create the sourcedirectory using your code above but my camera intent is unable to save the file into the source directory. I need to "chmod 777" before I can save the files. So, I think I need to check my camera intent code before I can further comment on this. But many thanks for your help. (and if it works, I will put that as the accepted answer) – kwytse Apr 11 '13 at 06:58