android 我可以访问 /data/user 上的文件吗
android can I get access to file on /data/user
我有一个 "shares" 文件的应用程序,如果用户想 "share" 使用文件资源管理器,它可以正确显示,我得到这种格式的文件:
/storage/emulated/0/Android/data/com.adobe.reader/files/Downloads/Getting Started.pdf
但是当 "sharing" 来自像 MS word 这样的应用程序时,我得到这个路径:
/data/user/0/com.microsoft.office.word/files/tempOffice/Share/7783958e-e851-4774-b28f-818e614b5991/Letteron.docx
所以问题是,我如何访问该文件 .docx
Gmail 等应用程序可以将其添加为附件,因此他们可以访问该文件...
您指的是实际的 .docx 文件吗?
如果我的理解正确,您可能需要先下载文件。 Google 有一个 API 的文档,可以直接从云端硬盘下载文件,这些文件应该是您需要的格式。
https://developers.google.com/drive/v3/web/manage-downloads
根据文档,标准语法是:
String fileId = "0BwwA4oUTeiV1UVNwOHItT0xfa2M";
OutputStream outputStream = new ByteArrayOutputStream();
driveService.files().get(fileId)
.executeMediaAndDownloadTo(outputStream);
但是,当然,请参考我上面链接的文档来弄清楚 pdf、word 文档等的语法。
我有一个 "shares" 文件的应用程序,如果用户想 "share" 使用文件资源管理器,它可以正确显示,我得到这种格式的文件:
/storage/emulated/0/Android/data/com.adobe.reader/files/Downloads/Getting Started.pdf
但是当 "sharing" 来自像 MS word 这样的应用程序时,我得到这个路径:
/data/user/0/com.microsoft.office.word/files/tempOffice/Share/7783958e-e851-4774-b28f-818e614b5991/Letteron.docx
所以问题是,我如何访问该文件 .docx
Gmail 等应用程序可以将其添加为附件,因此他们可以访问该文件...
您指的是实际的 .docx 文件吗?
如果我的理解正确,您可能需要先下载文件。 Google 有一个 API 的文档,可以直接从云端硬盘下载文件,这些文件应该是您需要的格式。
https://developers.google.com/drive/v3/web/manage-downloads
根据文档,标准语法是:
String fileId = "0BwwA4oUTeiV1UVNwOHItT0xfa2M";
OutputStream outputStream = new ByteArrayOutputStream();
driveService.files().get(fileId)
.executeMediaAndDownloadTo(outputStream);
但是,当然,请参考我上面链接的文档来弄清楚 pdf、word 文档等的语法。