Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 714
Warren Smith Avatar asked Jun 28 '26 18:06

Warren Smith


1 Answers

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.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!