[英]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?
我可以通过编程方式看到原始文件夹可能是最容易处理的,但对此有什么正确的策略?
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.