Android:保存持久数据
我还有另一个问题,我还没有时间去编码,所以请随意抱怨并告诉我先尝试一下。但我只是想知道是否有一种存储数据的方法,例如对图像的引用
,即我将有一个带有姓名、年龄等的客户对象,然后是包含在可绘制类中的图像。因此,当启动 Activity 时(第一次之后),我可以很容易地从数据存储中获取名称/年龄基元类型,但是当涉及到图像时,如果我存储它的 id,我将如何使用它作为参考对于位图加载器。显然要避免保留两张图像(应用程序提供的一张图像,以及如果我必须存储一张图像以保持与客户对象的关联)。
I have another question also, one I haven't yet got round to having a bash at coding yet so feel free to complain and tell me to try it first. But I just wanted to know if there is a way of storing data such as references to images
i.e I would have a customer object with a name, age etc and then an image which is contained within the drawable class. So when starting up the Activity (after the first time) I could obtain the name/age primitive types easy enough off of the data store but then when it comes to the image if I store it's id how would I then use that as a reference for the bitmap loader. To obviously avoid retaining two images (the one supplied with the app and if I had to store one to keep the association with the customer object).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除非您的应用程序的用户拥有一组常见且令人惊讶的静态客户集,否则您可能不希望将客户图像作为资源捆绑在您的应用程序中进行分发!将它们作为 blob 存储在数据库中。
Unless the users of your app has a common and amazingly static set of customers you probably don't want to distribute customer images bundled as resources in your app! Store them in the database as blobs.