简体   繁体   English

如何在Android中处理大量数据

[英]How to handle large amount of data in android

My app has several image and media files, which are around 1MB each or so. 我的应用程序有几个图像和媒体文件,每个文件约为1MB。 So if i follow the normal way, the app size is crossing over 40MB, which is huge. 因此,如果我按照通常的方式,应用程序大小将超过40MB,这是巨大的。 Is there anyway to avoid this? 反正有避免这种情况吗? I have heard of external storage, but i really don't get any clue of how to work on them! 我听说过外部存储,但是我真的不知道如何使用它们! Do i need to ask all those who instal this to save the images and media files in the external disk and then the app uses those? 我是否需要让所有安装此程序的人将图像和媒体文件保存到外部磁盘中,然后应用程序使用这些文件? This makes my files public..isn't it? 这使我的文件公开。不是吗? I actually don't own a android device. 我实际上并不拥有android设备。 So is it like, whenever people install an app from the market, does it ask if it has to install in the phone memory or the external memory? 就像这样,每当人们从市场上安装应用程序时,它会询问它是否必须安装在手机存储器或外部存储器中吗? I really need your help. 我真的需要你的帮助。 If there is a way, i'd be thankful if you can provide me the step by step details of how this can be done! 如果有办法,请您逐步提供详细信息给我,我将不胜感激!

Thanks a lot.. 非常感谢..

Regards Nithin 关于Nithin

You might consider streaming the files or downloading them inside the application to the sdcard. 您可能会考虑流式传输文件或将其在应用程序内部下载到sdcard。 Speaking from experience my users have had problems downloading apps as big as 30MB. 从经验来看,我的用户在下载最大30MB的应用程序时遇到了问题。 Some phones also have a severely limited internal memory, which is where the applications are downloaded to. 某些手机​​还具有严重受限的内部存储器,可将其下载到这些存储器中。

There is, from the little I know of this, a slight security risk from putting files onto the SD card. 据我所知,将文件放入SD卡存在轻微的安全风险。 I don't think I personally would worry too much about that since most people that would want access to the files in your apk (Which does not include your source code) could get it regardless without too much trouble. 我不认为我个人过于担心,由于将要访问您的apk文件( 包括你的源代码)可以得到它,无论没有太多的麻烦最多的人。

As of Android 2.2 the user has the option to move an app to their SD card, but only if the developer explicitly tells the app to allow it. 从Android 2.2开始,用户可以选择将应用移至其SD卡,但前提是开发人员明确要求该应用允许。 I'm fairly sure this only applies to 2.2+ devices though, so being that you are likely going for a larger audience than that it isn't an end-all solution. 我相当确定这仅适用于2.2+设备,因此与可能不是最终解决方案的用户相比,您可能会吸引更大的受众。 I am only really pointing this out in case you do end up putting one large file on the market. 我只是指出,以防万一您最终将一个大文件投放市场。 If so, be sure to allow the transfer to SD card, your app will stay on devices much longer. 如果是这样,请确保允许转移到SD卡,您的应用将在设备上停留的时间更长。

Downloading the files online from within the app and saving them out to the SD card would be a good solution, though I am not sure how end users feel about downloading a small app then having to download a very large package before using it. 从应用程序内部在线下载文件并将其保存到SD卡将是一个很好的解决方案,尽管我不确定最终用户对下载一个小型应用程序的感觉如何,然后在使用之前必须下载一个非常大的软件包。 In the end they will have to download it either way, so it is up to you whether you want to ask them to do it up front in the market or afterwards via the app. 最后,他们将不得不以任何一种方式下载它,因此由您决定是否要让他们先在市场上进行销售,还是之后再通过该应用程序进行下载。 If you do want to try to download all the content then maybe the code example in this link will help you figure it out : 如果您确实想下载所有内容,那么也许此链接中的代码示例将帮助您了解一下:

http://androidsnips.blogspot.com/2010/08/download-from-internet-and-save-to-sd.html http://androidsnips.blogspot.com/2010/08/download-from-internet-and-save-to-sd.html

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

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