黑莓数据库上的图像存储问题
我在我的 BlackBerry 移动应用程序中使用 SQLite 数据库,并且运行良好。
我想将相机捕获的图像保存到数据库中。相机捕获图像的大小是400k,但我将其缩小到7000字节。
当我尝试将其插入数据库时,它显示Blob 大小太大。数据库每次查询仅接受最多 4000 字节。
我怎样才能插入这张图片?有人可以指导我吗?
I am using SQLite database in my BlackBerry mobile application and it works fine.
I want to save a camera capture image to the database. The size of the camera capture image is 400k, but I reduce it to 7000 bytes.
When I am trying to insert it into the database, it shows Blob size is too Big. The database accepts only up to 4000 bytes per query.
How can I insert this image? Could anyone guide me please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
虽然一般来说SQLite 对 BLOB 有相当合理的限制,但事情是在 Blackberry 上受到更多限制。 (该限制实际上是在编译数据库引擎时设置的。)您可以使用第一页上的信息来实际找出限制的真正含义(但请注意,这可能会因 Blackberry 平台而异;这一点已注意到)在第二页上):
但是,第二个链接确实指出,最好在数据库中存储尽可能少的数据(好吧,要合理;如果需要数据,就应该在)与其余的作为普通文件存储的信息。对于图像,我建议将图像本身放入文件中,并仅将元数据(当然包括文件名!)保留在数据库中。这将解决大小限制,同时仍然允许相当丰富的查询。这样做会损失图像数据的事务存储(但如果您获得的回报是能够存储数据,那仍然是一笔不错的交易)。
While in general SQLite has pretty reasonable limits on BLOBs, things are much more constrained on a Blackberry. (The limit is really set at the time of compilation of the DB engine.) You can use the information on the first page to actually find out what the limit really is (though be aware that this may vary between Blackberry platforms; this is noted on the second page):
However, the second link does note that it is good practice to store as little data in the DB as possible (well, be reasonable; if data needs to be in, it should be in) with the rest of the information stored as normal files. In the case of images, I'd suggest putting the image itself in a file and keeping only metadata (including the filename, naturally!) in the database. That'll work around the size limits while still allowing reasonably rich queries. What you lose by doing this is transactional storage of the image data (but if what you are gaining in return is the ability to store the data at all, that's still a good trade).