简体   繁体   English

Android如何将文件从内部存储移动到外部临时文件夹?

[英]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.

相关问题 如何在Android上将文件从内部应用程序存储移动/重命名为外部存储? - How to move/rename file from internal app storage to external storage on Android? 如何从 android 的内部存储器中移动文件 a? - How to move file a from internal storage of android? 在Android中将文件从内部存储复制到外部存储 - Copy file from the internal to the external storage in Android Android从内部存储复制文件到外部 - Android copy file from internal storage to external Android - 从内部存储文件夹中选择文件 - Android - Select file from internal storage folder Android上内部/外部存储上的私有文件夹 - Private folder on Internal/external storage on android 如何在三星 A51 Android 10 的“内部存储”文件夹(主要外部存储)中创建文件? - How do I create a file in the “Internal Storage” folder (Primary External Storage) of my Samsung A51 Android 10? 在Android中的外部存储和内部存储上存储文件 - Storing file on External Storage and Internal Storage in android 如何将共享首选项文件从内部存储传输到外部存储? - How to transfer sharedpreferences file from internal storage to external storage? 将文件从应用程序内部存储器复制到android中的外部存储设备? - Copy file from application Internal memory to external storage in android?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM