存储通过相机拍摄的应用程序图像的最佳方式

发布于 2024-08-31 02:40:50 字数 339 浏览 1 评论 0原文

我只是想了解将图像存储为应用程序一部分的最佳方式。

我有一个代表“作业”的活动,其中有几个编辑文本,并且下面计划使用图库组件来显示与该作业相关的图像。

作业数据存储在数据库中(在 SD 卡上),因此还考虑创建一个表来存储“JobImages”并将每个图像存储为字节数组。

但我不确定将图像直接存储在 SD 卡上特定于我的应用程序和工作的文件夹结构下是否会更好。例如,使用作业 ID 号作为文件夹名称。

根据我使用的方法将极大地确定进入“适配器”的代码,该适配器允许我绑定到图库组件,因此在开始之前我想知道是否有人遇到相同的设计问题以及他们选择了什么选项。

谢谢,

戴夫

I'm just looking for some insight into what would be the best way for me to store images as part of my app.

I have an activity that represents a 'Job' which has a couple of edittext's and underneath was planning on using the Gallery component to show images relevant to this job.

The job data is stored in a database (on the sdcard) so was also thinking of creating a table to store 'JobImages' and having each image stored as a byte array.

But I'm not sure if it would be better to store the images directly on sdcard under a folder structure specific to my application and the job. E.g. using the job ID number as a folder name.

Depending on which method I use will greatly determine the code that goes into an 'adapter' that allows me to bind to the gallery component so before I begin I was wondering if anyone has had the same design problem and what option they chose.

Thanks,

Dave

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

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

发布评论

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

评论(1

月寒剑心 2024-09-07 02:40:50

无论您选择哪种存储方法,都不要让它阻止您编写将使用它的代码。编写一个类,从您的应用程序中抽象出它,并只为您提供图像,它如何/从哪里检索图像并不重要,这也将在将来帮助您,如果您决定更改存储方法,您只需要更改此类,而不是整个应用程序。

回到最初的问题,这取决于您将如何使用图像,如果您已经有一个数据库并且需要将图像与其他记录相关联或添加其他属性(即收容所中的动物及其图片和其他属性的数据库)属性),存储在数据库中是有意义的。如果您只关心不需要组织的图片(即内置图库),则将其存储在文件夹中。

以下是有关如何在数据库中存储的链接: http://www.helloandroid.com/教程/存储图像文件数据库

Regardless of what storage method you choose, don't let that stop you from writing the code that will use it. Write a class that abstracts this from your app and just gives you images, how/where it retrieves images from, doesn't matter, this will also help you in the future if you decide to change your storage method, you will only have to change this class, not the whole app.

Back to the original question, it depends how you'll be using the images, if you already have a db and need to associate the images with other records or add additional properties (i.e. a database of animals in a shelter with their pictures and other attributes), makes sense to store in a db. If all you care about are pictures that don't have any need to be organized (i.e. the built in Gallery), then store in a folder.

Here's a link on how to store in DB: http://www.helloandroid.com/tutorials/store-imagesfiles-database

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