Android,安全地(安全/无错误)且体贴地(不填充存储空间)存储几MB的应用程序数据?

发布于 2024-10-31 06:49:51 字数 396 浏览 6 评论 0 原文

我的 Android 应用程序是图像密集型的。出于对多种手机规格的考虑,我的应用程序将所有图像优化为更小,更易于处理需要它们的设备的尺寸。

目前这些存储在:

/data/data/com.myapp.example/files

但是我觉得有两个重要的考虑因素,

首先,应用程序在初始“设置”后将占用大约 10MB 的额外空间。我怎样才能让这个问题对用户来说尽可能小?我没有考虑将它们输出到 SD 卡,因为它们是许可材料,而 SD 完全不安全。 (尽管我完全知道来自root设备的数据目录也是如此)。这个问题的解决方案是什么?

我的第二个考虑因素是,在开始尝试使用用户设备之前,我需要能够知道用户设备上是否有足够的空间,在开始该过程之前,有什么方法可以找出答案吗?

My Android application is heavily image intensive. Out of consideration for the multiple phone specifications, my application optimizes all the images to smaller, easier to handle sizes for the devices that require them.

At present these are stored in:

/data/data/com.myapp.example/files

However I feel there are two important considerations to make,

First of all that the application will take up approximately 10MB of additional space after the initial "setup". How can I make this as small a problem as possible for the user? I havn't considered outputting them to the SD card because they are licensed material and SD is totally insecure. (although i'm totally aware that so is data directory from rooted devices). What would be the solution to this problem?

My second consideration is that I need to be able to know if there is enough space on the users device before I start trying to use it, is there some way I can find out before I begin the process?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

噩梦成真你也成魔 2024-11-07 06:49:51

为什么不将文件保存在 SDCard 上并使用某种强大的算法对其进行加密?正如您所说,/data 与 SDCard 一样安全...

要检查给定路径的可用空间,请使用 StatFs 类。


编辑11/04/2011:

你应该做一些测试来检查解密数据是否会太慢。你可能会有一个很好的惊喜。另请查看 TEABlowfish 算法似乎是最快的“强”算法之一。或者简单地使用您自己的非常简单的算法加密您的数据,这将防止直接撕裂图像(但无法抵抗更好的黑客)。

而且我认为手机上不会有任何安全区域可以临时存储解密的文件,因为任何 root 用户都可以访问手机的任何位置(并且 root android 对任何人来说都非常简单)


编辑 12/04/2011:

您一次需要全部 10MB 吗?不能将东西加载到内存中吗?如果您在应用程序启动时(和/或在后台)加载数据并在应用程序的生命周期内保持加载状态,您的应用程序是否会因 OutOfMemoryException 而崩溃?

最后一种可能性是使用某些本机接口解密/加载内存中的内容:内存在 Java 堆之外分配,这不会占用应用程序内存配额,并且解码速度将大大加快,因为本机代码的运行速度比等效的 Java 快得多代码。

Why not saving the files on the SDCard and encrypt them using some strong algorithm? As you say, /data is as secure as the SDCard ...

To check available space for a given path, use the StatFs class.


Edit 11/04/2011:

you should make some tests to check whether decrypting the data will be too slow or not. You might have a good surprise. Also check out TEA and Blowfish algorithms which seem to be amongst the fastest "strong" algorithms. Or simply encrypt your data using a very simple algorithm of your own which will prevent direct ripping of the images (but not resist to better hackers).

And I don't think there will be any secure area on the phone where to temporarly store decrypted files because any root user can access any place of the phone (and rooting an android is very simple for anyone)


Edit 12/04/2011:

Do you need all 10MB at once? Isn't loading stuff in memory possible? Is your application crashing with OutOfMemoryException if you load your data on application startup (and/or in the background) and keep it loaded during the life time of the application?

One last possibility would be to decrypt/load stuff in memory using some native interface : memory is allocated outside the Java heap which would not eat the application memory quota and decoding would be greatly speeded up as native code will run much faster than the equivalent Java code.

夜光 2024-11-07 06:49:51
  1. “尽可能小” - 好吧,如果您需要 10MB 的数据,那么您就需要 10MB 的数据。除了压缩数据之外,没有什么办法可以让它变小。当然,如果不需要所有这些数据,您可以考虑将数据分成单独的模块,并提供市场上的插件,或者让用户在启动时选择需要哪些数据,然后将其下载下来您自己的服务器。

  2. SD本身不安全,但您可以加密数据。当然,没有什么是万无一失的,但合理的加密算法会阻止随意复制数据。

  3. 无论您做什么,请记住在您的应用中启用“安装到 SD”选项。

  1. "As small as possible" - well, if you require 10MB of data, then you require 10MB of data. There's not much you can do to get it smaller, other than compressing the data. Of course, if not all of this data is required, you could consider splitting the data up into separate modules and either offer those on the market as plug-ins, or let the user choose which data is required on startup and then download it off your own server.

  2. SD itself is insecure, but you can encrypt the data. Of course, nothing is foolproof, but a reasonable encryption algorithm will stop casual copying of the data.

  3. Whatever you do, remember to enable the "install to SD" option in your app.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文