Create cursor from SQLiteStatement

I would like to use SQLiteStatement in my ContentProvider instead of the rawQuery or one of the other standard methods. I think using SQLiteStatement would give a more natural, native, efficient and less error prone approach to doing queries.

The problem is that I don't see a way to generate and return a Cursor. I realize I can use "call" and return a Bundle, but that approach requires that I cache and return all selected rows at the same time - this could be huge.

I will start looking at Android source code - I presume that "query" ultimately uses SQLiteStatement and somehow generates a Cursor. However, if anyone has any pointers or knowledge of this, I would greatly appreciate your sharing.

Answers


I would like to use SQLiteStatement in my ContentProvider instead of the rawQuery or one of the other standard methods. I think using SQLiteStatement would give a more natural, native, efficient and less error prone approach to doing queries.

Quoting the documentation for SQLiteStatement:

The statement cannot return multiple rows or columns, but single value (1 x 1) result sets are supported.

I fail to see why you would bother with a ContentProvider for single row, single column results, but, hey, it's your app...

The problem is that I don't see a way to generate and return a Cursor

Create a MatrixCursor and fill in the single result.


Need Your Help

Digitally signed e-mail with attachment

c# .net visual-studio-2010 email email-attachments

I have a mailer script which sends a single digitally signed e-mail. Now I have to attach file(s) to the mails. My issues:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.