Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android using a cursor on UI thread

I am wondering when or if its ok to use a cursor to get data from a sqlite database on the ui thread. Basically I use a cursorloader to get a cursor. And then I want to do something with that cursor. Is it ok to do something with the cursor from the main ui thread? Really I just need to read one row from the cursor.

like image 822
MobDev Avatar asked Apr 06 '26 22:04

MobDev


1 Answers

Retrieving a row from a Cursor is not an expensive operation... querying the data from the database, on the other hand, could be time-consuming depending on the amount of data you are requesting and/or the complexity of the query. CursorLoaders query for Cursors asynchronously so your approach is fine.

like image 91
Alex Lockwood Avatar answered Apr 08 '26 11:04

Alex Lockwood