Android 设备上的大型应用程序数据存储在哪里?

发布于 2024-10-04 02:33:56 字数 807 浏览 0 评论 0原文

我目前面临一个问题,我应该将我的对象结构存储在 Android 设备上。

用例:我正在开始调用应用程序服务器(在 的大力帮助下AsyncTask),从服务器获取众所周知的响应(xml-response),解析数据并将其最终转换为我的对象结构(高度复杂的类图,类之间有许多关联)。到目前为止,它正在工作,这要感谢伟大的 XMLPullParser ;) 我想知道在哪里存储(当然还有共享)我的活动之间获取的数据...我已经知道我可以使用 sqlite,但我没有 or-mapper(如 j2ee 环境中的 hibernate)。我也不允许将这些敏感数据存储在设备上(在 sqlite 或文件系统中),所以我的第一个方法是将这些数据存储在单例中(这当然是保存在内存中......)。但是当系统内存不足时会发生什么,android可以“销毁”存储在我的单例中的数据吗?我已经读过有关扩展 android.app.Application 类的内容。那么在 Android 设备上安全存储对象数据(从“webservice”调用)的最佳方法是什么?

顺便说一句:Android 开发就是这么酷!我们目前正在将 Windows Mobile 6.5 应用程序移植到 Android 和 iPhone,而我的同事(负责 iPhone 开发)一直在抱怨^^

I'm currently facing a problem where I should store my object structure on the android device.

The usecase: I'm starting a call to an applicationserver (with the great help of AsyncTask), get a well known response (xml-response) from the server, parse the data and transform it finally into my object structure (highly complex class diagram with many associations between the classes). So far it's working, thanks to the great XMLPullParser ;)
I'm wondering where to store (and of course share) the fetched data between my activities... I already know that I can use sqlite, but I do not have an or-mapper (like hibernate in the j2ee environment). I'm also not allowed to store this sensitive data on the device (in sqlite or file system), so my first approach was to store this data in a singleton (which is of cource being held in memory...). But what happens when system is getting on low memory, can android "destroy" the data stored in my singleton? I already read about extending the android.app.Application class... So what is the best way to securely store object data (called from "webservice") on android devices?

BTW: Android development is that cool! We are currently porting a Windows Mobile 6.5 App to Android and iPhone, and my colleague (reponsible for iPhone-dev) is complaining all the time^^

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

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

发布评论

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

评论(1

趁年轻赶紧闹 2024-10-11 02:33:56

关于 OR 映射器,前几天我遇到了 OrmLite。它是 Java 的通用 ORM 工具,但它也有一些特殊的修改,使其适用于 Android。我还没有时间亲自测试它,但它看起来很有希望:)

至于在手机上存储敏感数据,您确实无法选择仅将其存储在内存中(按照您的建议使用某种单例) )。一旦您的应用程序进入后台,它就会立即被终止,因此您必须以某种方式保留您想要保留的数据。话虽这么说,如果您将数据保存到 内部存储 ,这对于手机上的任何其他应用程序不可用(假设手机未获得 root 权限,因为如果获得 root 权限,则很容易绕过)。我确实相信这同样适用于使用 SQLite 存储的数据,但我不能 100% 确定,所以我不会保证这一点。

但基本上,如果您确定您的应用程序只能在非 root 设备上运行,那么您应该可以非常安全地将数据保存到内部存储中。如果这还不够好,还有 javax.crypto< /a> 包,但我从未使用过它,所以我不能对此说什么。

Regarding an OR mapper, I came across OrmLite the other day. It is a general ORM tool for Java, but it also has some special adaptations that makes it work for Android. I haven't had time to test it myself yet, but it looks promising :)

As for storing sensitive data on the phone, you really don't have the option of storing it only in memory (using some kind of singleton as you suggested). As soon as your application goes to the background, it can be killed instantaneously, so you have to persist what data you want to keep in some way. That being said, if you save data to Internal Storage, this will not be available for any other app on the phone (given that the phone is not rooted, because if is rooted this is easy to get around). I do believe that this same goes for data you store using SQLite, but I'm not 100% certain, so I won't guarantee it.

But basically, if you are sure that your app will only run on non-rooted devices, you should be pretty safe saving your data to Internal Storage. And if that isn't good enough, there there is the javax.crypto package, but I've never used that so I can't really say anything about it.

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