Bonjour,

J'essaye de deplacer un fichier avec la methode renameTo() mais ca ne marche pas... je sais pas pourquoi

Si quelqu'un a deja essayé et a une solution !

Le logcat
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
06-03 15:32:17.800: E/dirPath(7069): /mnt/sdcard/Dir
06-03 15:32:17.800: E/filePath(7069): /54_2013-06-03_15:32.mp4
06-03 15:32:17.835: E/oldPath(7069): /mnt/sdcard/DCIM/Camera/VID_20130513_143336.mp4
06-03 15:32:17.922: E/VideoMover(7069): move
06-03 15:32:17.922: E/VideoMover(7069): failed
Le code (avec tout les logs pour savoir pourquoi ca veut pas x))

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import android.os.Environment;
import android.util.Log;
 
import java.io.File;
 
public class VideoMover implements Runnable {
    private File _dirPath;
    private String _filePath;
    private String _oldPath;
    private boolean _isSuccess;
 
    public VideoMover(String path, int vitesse, String date)
    {
        this._dirPath = new File(Environment.getExternalStorageDirectory(), "/Dir/");
        if (!this._dirPath.exists()) {
            Log.e("Dir", "doesn't exist");
            this._dirPath.mkdir();
        }
        if (!this._dirPath.canWrite()) {
            Log.e("Dir", "can't write");
        }
        this._filePath =  "/" + String.valueOf(vitesse) + "_" + date.replace(' ', '_') + ".mp4";
        this._oldPath = path;
        Log.e("dirPath", this._dirPath.getPath());
        Log.e("filePath", this._filePath);
        Log.e("oldPath", this._oldPath);
    }
 
    @Override
    public void run() {
        Log.e("VideoMover", "move");
        File move = new File(this._oldPath);
        if (!move.canRead()) {
            Log.e("move", "can't read");
        }
        if (!move.exists()) {
            Log.e("move", "doesn't exist");
        }
        this._isSuccess = move.renameTo(new File(this._dirPath, this._filePath));
        if (_isSuccess) {
            Log.e("VideoMover", "success");
        }
        else
            Log.e("VideoMover", "failed");
    }
}
Merci d'avance !