[英]Android how to move file from internal storage to external temporary folder?
hi i'm trying to open a doc file in quick office from my app but it doesn't seem to be allowed access to get the file from my internal storage. 嗨,我正在尝试从我的应用程序在Quick Office中打开一个doc文件,但是似乎不允许它从我的内部存储中获取该文件。 so what i'm wanting to do is move the file from internal storage to a temporary folder on the external storage so that when it can be opened by quick office?
所以我想做的就是将文件从内部存储移动到外部存储的临时文件夹中,以便快速办公室打开它? does anyone know if this is possible
有谁知道这是否可能
String source = // Internal file path
String destination = getExternalCacheDir() + "/" + UUID.randomUUID();
FileInputStream fis = new FileInputStream(source);
FileOutputStream fos = new FileOutputStream(destination);
byte[] buf = new byte[1024];
int len;
int total = 0;
while ((len = fis.read(buf)) > 0) {
total += len;
fos.write(buf, 0, len);
if (total > 20 * 1024) {
fos.flush();
}
}
fis.close();
fos.close();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.