Search code examples
androidandroid-sqliteandroid-cursor

How many cursor we can open in sqlite database?


I have database with single table .Table contains around 7000 rows and only 3 columns including primary key.

When i use cursor operation it is blocking my UI.

You can refer these questions for that .

link 1

link2

Now due to this , i am in a situation to try out a new thing if possible.

I want your clarification that if it is possible or not .

Question is : can we use more than one cursor to read data from database.

For example 7 cursor , each can read 1000 rows from table and meanwhile i show progress dialog .

So i complete this database operation when user is not using UI .

Let me know can this be done . If you provide some code snippet , it will be best.

Thank you for your time .


Solution

  • Multiple cursors should not be done, it would be a programming nightmare to manage. If the cursor is locking the UI then you should run database query within an ASyncTask, hopefully http://www.vogella.com/articles/AndroidBackgroundProcessing/article.html will help you to do an ASyncTask.

    Any tasks that take a long time to complete, should always be done on a separate thread such as an ASyncTask otherwise the user will be presented with an ANR (Application Not Responding).