Android将相册中的图片保存到指定的app目录下面。下次调用的时候直接从自己app目录下找,不再去找相册。
1条回答 默认 最新
灯塔@kuaidao 2022-05-13 18:13关注实现方案网上很容易可以找到。贴一个基础做法.
/** * 复制单个文件 * @param oldPath 原文件路径 如:c:/fqf.txt String * @param newPath 复制后路径 如:f:/fqf.txt */ public static void copyFile(String oldPath, String newPath) { try { int bytesum = 0; int byteread = 0; File oldfile = new File(oldPath); if (oldfile.exists()) {//文件存在时 InputStream inStream = new FileInputStream(oldPath);//读入原文件 FileOutputStream fs = new FileOutputStream(newPath); byte[] buffer = new byte[1024]; int length; while ((byteread = inStream.read(buffer)) != -1) { bytesum += byteread;//字节数 文件大小 System.out.println("完成"+bytesum+" 总大小"+fileTotalLength); fs.write(buffer, 0, byteread); } inStream.close(); } } catch (Exception e) { System.out.println("复制单个文件操作出错"); e.printStackTrace(); } }本回答被题主选为最佳回答 , 对您是否有帮助呢?解决评论 打赏 举报无用 1