Boy
Boy

Reputation: 7497

content provider without database but saved cursors: can/need I close the queried cursor?

I have question regarding using a content provider without a database.

This has a list/HashMap with matrixcursors. When a query is being done on the content provider, the requested data is being returned by saying (this is pseudocode)

MatrixCursor mc = someMap[2];
return mc;

What if the quering client closes the cursor? I guess the cursor in someMap will also be closed, as the returned cursor is a reference to that object. Am I correct here?

Edit:

I am wondering if the getContentResolver() mechanism always takes care of a copy of the cursor, as query() is not a direct method call

Upvotes: 0

Views: 227

Answers (1)

Snicolas
Snicolas

Reputation: 38168

We don't have enough element to answer your question as you don't show your hashmap and how you fill it.

But in Java, if you do :

Cursor cursorA =  new ....
Cursor cursorB = cursorA;
Cursor cursorC = getCursorAViaAMethod();

cursorC, cursorB and cursorA are references (names in your code) of the same java object. Thus closing one, will close them all.

Upvotes: 1

Related Questions