正确使用Android SQLiteStatement的simpleQueryForBlobFileDescriptor()
Android 的 SQLiteStatement 中的 simpleQueryForBlobFileDescriptor() 函数对我来说是个谜。而且似乎没有人在任何地方使用它。看起来这对于单个 blob 访问来说是一种快速方法,并且在性能方面(如果文档可信的话),当用于从数据库中流式传输 blob 数据时,SQLiteStatement 和 Parcel 的组合应该会产生非常快的结果。我不知道,因为我无法让这个东西工作,以便我可以测试...对此的任何帮助或见解将不胜感激:
SQLiteStatement get = mDb.compileStatement(
"SELECT blobColumn" +
" FROM tableName" +
" WHERE _id = 1" +
" LIMIT 1"
);
ParcelFileDescriptor result = get.simpleQueryForBlobFileDescriptor();
// now what?
我可能应该注意到我正在使用并且只真正关心 Honeycomb (3.2)并提前感谢您的任何见解。
The function simpleQueryForBlobFileDescriptor() in Android's SQLiteStatement is a mystery to me. And no one seems to use it anywhere. It seems as though it would be a fast method for individual blob access and in terms of performance (if the documentation is to be believed) the combination of SQLiteStatement and Parcel should yield a very fast result when used to stream blob data out of a db. I don't know because I can't get the thing to work so that I could test... Any help with this or insight would be appreciated:
SQLiteStatement get = mDb.compileStatement(
"SELECT blobColumn" +
" FROM tableName" +
" WHERE _id = 1" +
" LIMIT 1"
);
ParcelFileDescriptor result = get.simpleQueryForBlobFileDescriptor();
// now what?
I should probably note that I am using and only really care about Honeycomb (3.2) and thank you in advance for any insight.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可以验证这对于我的用例来说非常快。
我发现这特别有用的地方(如果您需要像我一样创建自己的自定义离线 webview 文件缓存)是在内容提供者的 openFile 覆盖中,您可以直接返回描述符(或者理想情况下覆盖 openTypedAssetFile())
<强>例子:
files 是一个数据库助手, getFileDescriptor(String) 与上面的代码类似
,或者是解决类似问题的另一个很好的用途:
(您想要将自定义文件从数据库提供给网络视图)
and I can verify that this is very fast for my use cases.
Where I found this particularly useful (if you need to create your own custom offline webview file cache like I did) was in the openFile override for a content provider where you can just return the descriptor straight up (or ideally override openTypedAssetFile())
examples:
files is a DB helper and getFileDescriptor(String) is similar to the code above
or another great use for a similar problem:
(where you want to serve custom file from a db to a webview)