Warren Smith
Warren Smith

Reputation: 33

Convert JSON to Cursor

I have some data in JSON format that I'd like to convert into a cursor so it can be returned by a content provider. What's the best way to go about this?

I considered using a MatrixCursor but my content provider needs to return type Cursor, not MatrixCursor.

Any suggestions would be much appreciated!

Thanks.

Upvotes: 3

Views: 2036

Answers (1)

user1521536
user1521536

Reputation:

MatrixCursor extends AbstractCursor, AbstractCursor implements CrossProcessCursor, and CrossProcessCursor implements Cursor. So you can use MatrixCursor in your content provider.

But note that even you can put a byte[] array into MatrixCursor, however Cursor.getBlob() returns wrong value in older APIs. There was an issue (it was fixed). I couldn't remember or find the link to the issue but you can easily test it on emulators :-) Or here is a related question: Passing binary blob through a content provider.

Upvotes: 2

Related Questions