简体   繁体   English

res / raw,assets或sdcard?

[英]res/raw, assets or sdcard?

I am developing an app which is heavy on images, videos and other resources. 我正在开发一个对图像,视频和其他资源很重的应用程序。 What would be the proper place to store all this info? 什么是存储所有这些信息的适当位置? I can see that programmatically the raw folder is probably the easiest to handle, but what is the correct policy to this? 我可以通过编程方式看到原始文件夹可能是最容易处理的,但对此有什么正确的策略?

  • Assets is really bad place for items that are already compressed - when you build your app those will be tried to be compressed and this will have performance impact. 对于已经压缩的项目,资产是非常糟糕的地方 - 当您构建应用程序时,这些将被尝试压缩,这将对性能产生影响。 Also in decompression. 也在减压。
  • Res / raw is a good way to go if you have the images in advance, especially if you do not wan to download them after launching the app, thus having the user to wait. 如果您提前拥有图像,Res / raw是一个很好的方法,特别是如果您在启动应用程序后不想下载它们,从而让用户等待。
  • Sdcard should give you the most space. SD卡应该给你最大的空间。 However, you will either need to download the resources from the net, I can not think of a way you ship them with the application and them move them to the sdcard. 但是,您需要从网上下载资源,我无法想到您使用应用程序发送它们的方式,并将它们移动到SD卡。 When you download the resources from the internet make sure you store them in a subfolder of: 从Internet下载资源时,请确保将它们存储在以下子文件夹中:

     private File getResourceFilePath(String ralativePath, Context context) { if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { return new File(context.getExternalFilesDir(null), ralativePath); } else { return new File(context.getFilesDir(), ralativePath); } } 

Otherwise you risk the resources being available in the Gallery of the user's device etc. 否则,您可能会冒用户用户设备的图库中的资源等风险。

Keep in mind that if you store it in the res or raw folder it will be included in your apk file which will make your compiling and uploading to the play store longer and also make user downloads and updates from the play store take longer. 请记住,如果您将它存储在res或raw文件夹中,它将包含在您的apk文件中,这将使您编辑和上传到游戏商店的时间更长,并且还可以使用户从Play商店下载和更新花费更长时间。

If the media is pretty static and over a few megs, make it a zip file that gets downloaded on the side and stored in a separate folder, that the user can pick. 如果媒体非常静态并且超过几个meg,请将其设置为一个zip文件,该文件可以侧面下载并存储在用户可以选择的单独文件夹中。 That way you can update the media separate from updating the application. 这样,您可以更新媒体,而不是更新应用程序。

If you go down the zip file route, you should check out the APK expansion file support that google play has. 如果你沿着zip文件路线走下去,你应该查看谷歌播放的APK扩展文件支持。 http://developer.android.com/google/play/expansion-files.html http://developer.android.com/google/play/expansion-files.html

Note that if you use the expansion, other stores (Amazon, Nook, etc.) will still need the download a zip file support in your app. 请注意,如果您使用扩展,其他商店(亚马逊,Nook等)仍然需要在您的应用程序中下载zip文件支持。

-James -詹姆士

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

相关问题 / assets或res / raw中的Android映像 - Android images in /assets or res/raw 将raw或assets文件夹中的音频文件保存到sdcard android - save audio file in raw or assets folder to sdcard android 使用资产或res / raw文件夹时是否存在重大差异或限制? - Are there any major differences or restrictions when using assets or res/raw folders? 资产文件夹中的XML文件无法访问res / raw文件夹 - XML file in assets folder cannot access res/raw folder 从资产或res / raw中获取Uri文件 - Get Uri from file in either assets or res/raw Android:无法加载res / raw文件或资产 - Android: Neither res/raw files nor assets can be loaded 如何打开存储在res / raw或assets文件夹中的pdf? - How to open a pdf stored either in res/raw or assets folder? 如何将sdcard中的.txt文件复制到我的应用程序res / raw文件夹中 - How to copy a .txt file from sdcard to my app res/raw folder 将文件从res / raw复制到SD卡以使用Intent发送。ACTION_SEND - Copy a file from res/raw to SDcard to send using Intent.ACTION_SEND 如何通过将音频保存在sdcard上或使用应用程序的安装地址来访问原始或资产文件夹中的音频? - How to access an audio in raw or assets folder by save it on sdcard or using app's installation address?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM