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");
}
} |
Partager