简体   繁体   English

Android-如何将文档打包到应用中

[英]Android - How to package documents into an app

I'm trying to create an app and have the ability to save files to /data/data/(packagename)/files or a directory similar to that. 我正在尝试创建一个应用程序,并能够将文件保存到/ data / data /(packagename)/ files或类似的目录中。 The goal would be to have a pdf or doc handler, as necessary, open the files stored on the internal storage and be viewed by the user. 目标是根据需要拥有pdf或doc处理程序,打开存储在内部存储器中的文件,并由用户查看。 I have the code to get a pdf reader that is installed and display the file but I do not know how to package the files so they are installed in a directory like the one above. 我有获取安装的pdf阅读器并显示文件的代码,但我不知道如何打包文件,因此将它们安装在上述目录中。 Also, if I am able to do this would I use getResources to access the files? 另外,如果能够执行此操作,是否可以使用getResources访问文件? How should the file structure look in eclipse to make this happen on install of the APK? 文件结构应如何在eclipse中查看,以使其在安装APK时发生?

I do prefer to have the files stored internally (they are small) and not on the SD card. 我确实更喜欢将文件存储在内部(它们很小),而不是存储在SD卡上。

I admit I am new to this and am trying to learn as I go. 我承认我对此并不陌生,并且正在尝试学习。 Thanks for the help! 谢谢您的帮助!

As I understand your approach you only need to place your files to assets folder of your application and then just copy them to the internal storage. 据我了解,您只需要将文件放置到应用程序的资产文件夹中,然后将它们复制到内部存储中即可。 Read more here . 在这里阅读更多。

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

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