In Wallpaper Changer application version 1.2.* we added feature which allows to move file in application’s file manager.
I want to show how we did it. As you see this post refer to core Java not Android. That’s why I will post code with method main.
Example is simple,just copy it and use.
import java.io.File;public class Main{ public static void main(String[] args){ // File (or directory) to be moved File file = new File("C:/sampleDir/sample.data"); // Destination directory File dir = new File("C:/sampleDir/otherDir"); // Move file to new directory boolean success = file.renameTo(new File(dir,file.getName())); if (!success){ System.err.println("Error"); } }}That’s all,we moved file/directory.
No related posts.

Recent Comments