Shared sqlite database not refreshing

Hi,


We have 2 apps sharing a sqlite database. Everything goes well - except once app2 writes something to the databse, app1 does not reflect this information. If we kill the apps and restart app1, the information displays. It's almost like the data in app2 is not being flushed or somehow app2 retains a lock on the data and does not let app1 read it. Has anyone encountered this ?


Thanks

Regards,

Asheesh

Which platform (iOS or OS X) are you sharing the database on, and how are you sharing the database?


On iOS, in particular, there's a lot of extra coordination effort you're likely to need to do if you're trying to share a database file on the device locally.

The apps are on iOS. We are using the shared app group approach - so we have an app group that is added to the entitlements of each app id. We then use containerURLForSecurityApplicationGroupIdentifier to access the shared database.


Access the shared database is working, however, it seems like the updates to tables from app2 are now showing up immediately in app1. It takes killing the apps for the updates to show up.


Thanks

Regards,

Asheesh

Can you show your Info.plist?

So what are you using in App1 to detect that the shared resources have changed?


Do you have an NSFileCoordinator set up to notify your app when the file changes so you update the appropriate views? If not, do you have code in the various app-state notification methods to check whether what you're displaying is now out of date?

We figured out that the App 1 managed context had to be refreshed from the backing store - in this case sqlite. Calling refreshAllObjects before updating App1 views refreshes the data and resolves the issue. For example :

[[self managedObjectContext] refreshAllObjects];


Thanks to everyone for thier suggestions.

Shared sqlite database not refreshing
 
 
Q