2

I am working on project. In that project there are three timers is running through out the application after login. In each timer, we are calling approx 10-15 APIs for either upload data on server or fetch data from server. We are facing following issues-

  • We are unable to do data processing in background, due to this when we fire SELECT query to search records then SQLITE gives error "Database is locked".
  • So we are doing all data processing thing on Main thread, It actually creating UI freeze issue, whenever we call APIs.

Please suggest how we can do this process, so that User can search records from SQLITE DB at same time device can call APIs and can insert/update/upload records.

Note: There 2.2 Million Records in table in SQLITE Database.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
  • 1
    the first point you did not close the SQLite database after opening it that, why you are getting error 'Database, is locked'. Look at this link https://stackoverflow.com/questions/8853954/sqlite-error-database-is-locked. now close the database once you open it. Now you can use as many as secondary thread for database access whether it is SQLite or Coredata. – Gagan_iOS Aug 29 '17 at 09:59
  • This might help you to understand deeper. http://www.sqlite.org/threadsafe.html – PradeepKN Aug 29 '17 at 10:13
  • Thanks but we closed data base every time. There are too many records in table so, sqlite takes 7-8 seconds to search record, meanwhile if another query is being fired from background then this error occurred "Database is locked". So we do all query processing task in main thread. – Sujeet Shrivastav Aug 29 '17 at 10:15

0 Answers0