gpt4 book ai didi

android - HTML 5 应用程序将文件下载到与应用程序相同的目录

转载 作者:行者123 更新时间:2023-11-28 20:09:56 24 4
gpt4 key购买 nike

我正在使用 Phonegap 创建一个 html 5 应用程序,我希望能够从互联网上下载一个文件,并将其存储在应用程序所在的同一目录中。因此,我的应用程序将打开 index.html,并且需要将文件保存在该文件夹中。之后,它需要检查它是否有互联网连接,如果没有,它需要打开我刚刚下载的文件。我怎样才能做到这一点?我相信如果你只是下载它,它会进入默认下载 map 。此外,在 Android 或 iOs 设备上下载/保存此文件时会有差异吗?

最佳答案

I would like to be able to download a file from the internet, and store it in the same directory as the app is in.

由于安全原因,大多数平台都无法写入应用程序的安装位置。

但是,您可以使用 File 写入持久位置。 API。

it needs to check if it has internet connection, and if not, it needs to open the file I just downloaded. How can I do this?

这有两个部分,首先是检查互联网连接,这可以使用 Connection 来完成。目的。后一部分可以再次使用 File 完成。 API。

关于android - HTML 5 应用程序将文件下载到与应用程序相同的目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20702086/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com