问题描述
似乎有在Android上的光标窗口大小1MB的限制,限制从SQLite的读取BLOB的能力。我知道你会说我们不应该存储BLOB在数据库中,但根据定义,BLOB被认为是一个二进制大对象,如果没有必要将它们存储在数据库中,没有必要在任何数据库引擎来实现这样的对象类型。
There seems to be a 1MB limit on Android's Cursor Window size which limits the ability to read BLOBs from SQLite. I know you may say we should not store BLOBs in database but by definition, BLOB is considered a Binary Large Object and if there was no need to store them in database, there was no need to implement such object type in any database engines.
光标执行情况的1 MB的限制然而,似乎是不够的几乎所有情况下。我需要存储我的二进制数据在SQLite数据库正当理由,他们超过1 MB。 SQLite是能够处理BLOB的完美,因为C API是工作完全正常的X code(iPhone平台)来获取大的物体没有任何问题。
The 1 MB limit on the implementation of Cursor however, seems to be insufficient in almost all cases. I need to store my binary data for valid reasons in SQLite database and they are well over 1 MB. SQLite is capable of handling BLOBs perfectly since the C API is working perfectly fine in Xcode (iPhone platform) to retrieve large objects without any issues.
我的问题是,如果我们都不可能访问Android的BLOB数据,而无需使用游标。我想到的SQLite的较低级别的访问Java中。有什么建议?
My questions is if we can possibly access the BLOB data in Android without using cursors. I am thinking of a lower level access to Sqlite in Java. Any suggestions?
推荐答案
作为CL提到的,使用NDK的确是一种通过C语言在Java语言访问sqlite的本身。然而我意识到它可能带来麻烦,如果我想写一个自定义包装自己,尝试访问功能的Java。
As CL mentioned, using NDK is indeed a way to access Sqlite natively via C language in Java language. However I realized it could get really messy if I wanted to write a custom wrapper myself and try to access the functions in Java.
摸索之后,我遇到了所谓的Sqlite4java辉煌的开源项目,它是围绕sqlite的一个紧密的包装,编译在不同的平台,包括Android的使用。该库允许你使用SQLite来交互,而采用Android光标从而消除了限制。
After searching around, I came across a brilliant open source project called Sqlite4java which is a tight wrapper around Sqlite, compiled to use on various platforms including Android. This library allows you to interact with Sqlite without using Android Cursor which removes the limitations.
我能够找回20 MB的Blob在480毫秒。这甚至不是通过游标读取sqlite的一个小纪录快。我相信这可以用来增强任何查询,通过跳过使用光标的SQLite的。这里的链接到这个伟大的图书馆: HTTP://$c$c.google.com/ P / sqlite4java /
I am able to retrieve 20 MB of Blob in 480 milliseconds. This is even faster than reading a small record from Sqlite via Cursors. I believe this can be used to enhance any query to Sqlite by skipping the use of Cursor. Here's the link to this great library: http://code.google.com/p/sqlite4java/
这篇关于访问大型BLOB在Android的SQLite的无光标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!