Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is a cursor thread safe in Android

Tags:

android

cursor

I have a content provider which is going out to some record sources in the cloud and doing queries, the results are added to a cursor reference that is passed into those classes

WebSearch1.addCursor(mContext, cursor, projection, filter);
WebSearch2.addCursor(mContext, cursor, projection, filter);

Works great, but it is asynchronous, would like to kick it off in a async task/thread to improve response times. I could create a cursor in for each of the sources, and then add them into a MergeCursor. Not a huge deal to do it that way, but just wondering if the cursor is thread safe to pass off to two different threads to add to the cursor synchronously.

Thanks,

like image 246
Chrispix Avatar asked Aug 28 '26 06:08

Chrispix


1 Answers

This interface provides random read-write access to the result set returned by a database query. Cursor implementations are not required to be synchronized so code using a Cursor from multiple threads should perform its own synchronization when using the Cursor.

like image 148
L7ColWinters Avatar answered Aug 29 '26 19:08

L7ColWinters



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!