Partage
  • Partager sur Facebook
  • Partager sur Twitter

Deplacer un fichier -> Impossible...

    3 juin 2013 à 17:36:28

    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

    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))

    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 !

    -
    Edité par twx 3 juin 2013 à 17:39:30

    • Partager sur Facebook
    • Partager sur Twitter

    Deplacer un fichier -> Impossible...

    × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
    × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
    • Editeur
    • Markdown