Move and rename file in android

Posted by Andre Fróes on Stack Overflow See other posts from Stack Overflow or by Andre Fróes
Published on 2014-06-10T15:22:06Z Indexed on 2014/06/10 15:24 UTC
Read the original article Hit count: 168

Filed under:
|
|
|

I am trying to copy a file to another folder in the android, but so far, i got no success. I manage to do so with a selected image and when taking a photo, but not with files.

I've read and tried several solutions passed by the community (searched over the forum and the internet), but none of it was able to solve my problem when copying.

First things first. I added the permissions to my manifest:

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

after that, before copying a file, i print its filepath and the directory file path:

06-10 11:11:11.700: I/System.out(1442): /mimetype/storage/sdcard/Misc/Javascript erros for Submit and Plan buttons in IE.doc 06-10 11:11:11.710: I/System.out(1442): /storage/sdcard/mywfm/checklist-files

both exists:

to copy the file to the expected folder I used the FileUtils:

        try {
            FileUtils.copyFile(selectedFile, dir);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

The problem is: I get no exception and the file isn't there. I tried this solution either: How to move/rename file from internal app storage to external storage on Android?

same thing, no exception, but no file either.

© Stack Overflow or respective owner

Related posts about java

Related posts about android