简体   繁体   English

构建后访问内部文件-Cordova

[英]Access internal files after built - Cordova

I am wondering if is possible accessing the internal files of an app after build with cordova plugin. 我想知道用cordova插件构建后是否可以访问应用程序的内部文件。

My project is based on Android and here are my files: 我的项目基于Android,这是我的文件:

index.html html: - remove.html js css

So, after build the app, I want to access with some option within the app the remove.html and remove it. 因此,在构建应用程序之后,我想使用应用程序内的某些选项访问remove.html并将其删除。 I find that the FILE plugin of cordova is useful for files inside the device but not the app. 我发现cordova的FILE插件对设备内部的文件很有用,但对应用程序却没有帮助。 Please anyone has any idea? 请任何人有任何想法吗?

we do not have modification access to the location where apk's internal files are saved. 我们没有对APK内部文件保存位置的修改权限。 Since your remove.html is part of your app apk, we cannot just remove it. 由于您的remove.html是应用apk的一部分,因此我们不能仅将其删除。

You can take the same approach taken by sqlite raw database file. 您可以采用sqlite原始数据库文件所采用的相同方法。 When your app is started or run for the very first time, copy your file ( remove.html ) to data folder where you can modify/delete it. 当您的应用程序首次启动或运行时,请将文件( remove.html )复制到data文件夹中,您可以在其中修改/删除它。 Make sure your app only uses this new path everywhere. 确保您的应用仅在所有地方都使用此新路径。

Take a look at copyDatabaseFromAssets function in this code for a sample on how do this. 查看此代码中的copyDatabaseFromAssets 函数,以获取有关如何执行此操作的示例。 Since you will have modification access, you can delete or modify this file as needed. 由于您具有修改权限,因此您可以根据需要删除或修改此文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM