2

I'm using geofencing,when user enter to the region I check the region id from local data base,if it is valid then display it.Then update local data base too.Problem is when application in active all works fine.When application in background state(passcode lock screen) didn't insert data to the data base. Also i try this one How run sqlite in background on the iPhone? NSOperationQueue but didn't work.

Any one have idea

Community
  • 1
  • 1
mychar
  • 1,031
  • 1
  • 11
  • 20
  • Are you getting any error messages? Have you enabled file protection for your app? If so then it is possible that your database is not available when the device is locked. – Paulw11 Mar 28 '14 at 06:55
  • how to enable fileprotection – mychar Mar 28 '14 at 07:22
  • no error massages just null i cant find how to enable file protection – mychar Mar 28 '14 at 07:31
  • 1
    You enable file protection from the capabilities on your project & by assigning protection levels in your app - since you don't know how to do it, you probably haven't done it. Some operation must be failing - have you but NSLog statements in when errors are detected? Have you put a breakpoint in? You can run in the simulator and simulate location changes to trigger your geofence. – Paulw11 Mar 28 '14 at 08:59
  • Unknown error calling sqlite3_step (14: unable to open database file) eu – mychar Mar 28 '14 at 13:47
  • @Paulw11 you save me.disable data protection and clear all run again.its works now thank u again for the help – mychar Mar 28 '14 at 15:07
  • Great. I have added this an answer. If you could accept that would be great – Paulw11 Mar 28 '14 at 20:04

1 Answers1

3

You need to disable data protection from your capabilities tab on the XCode project as it is denying access to your data while the device is locked.

If you have other sensitive data in your project that you want to protect then you can apply a reduced file protection level to your SQLite database.

Have a look at NSFileProtectionNone attribute and the setAttributes:ofItemAtPath:error: method in NSFileManager.

Paulw11
  • 108,386
  • 14
  • 159
  • 186
  • it is already disable but still m getting error Unknown error calling sqlite3_step (14: unable to open database file) and when i unlock the device the it automatically starts saving data to database – Patel Jigar Oct 24 '15 at 09:09