这个问题可能在其他地方被问过,但对我没有用。
我将图片保存在app-private文件夹中,用户可以选择将图片移至Android图库。所以我的问题是如何做到这一点?
这是我的代码
String outPath = "new path which is gallery";
File outFile = new File(outPath);
// File (or directory) to be String
sourcePath="image in the app-private folder";
File file = new File(sourcePath);
// Destination directory
boolean success = file.renameTo(new File(outFile, "name of image"));
System.out.println("success: "+success);
这里的成功总是“虚假”