5

I am developing two iOS app and I want to access their database from each other.

Eg. APP1 and APP2 both developed by me, APP1 can access APP2 database and vice-versa

I read somewhere that same iOS app developer can have sandbox access authorities to access their own developed iOS app.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
hpDev_iOS
  • 170
  • 9
  • No, where did you read that. Its only possible if you are developing extensions with your app using group identifiers. – iphonic Jun 01 '15 at 10:24
  • i think facebook app and facebook messenger app having some access authority with in each other sandbox or database. – hpDev_iOS Jun 01 '15 at 10:29
  • @hpDev_iOS facebook app and facebook messenger both communicate with facebooks servers. If you provide a server that your two apps can communicate through, then you can share data. – Kyle Jun 01 '15 at 10:47
  • ok....But using same groupId with in 2 iOS app, can i access each other database? – hpDev_iOS Jun 01 '15 at 10:54

3 Answers3

2

Yes, you can do this. You create an app group, put both apps in the same app group. Any files created in the shared file area are available to both apps. It works exactly the same way an extension shares files with its host app.

I'm currently using this to share a SQL DB between two different apps.

The shared file are can be accessed via the file manager:

NSFileManager* fileMgr = [NSFileManager defaultManager];
NSURL* sharedDirectory = [fileMgr containerURLForSecurityApplicationGroupIdentifier:appGroupId];
progrmr
  • 75,956
  • 16
  • 112
  • 147
-1

It is true, that you can't access files from one app in another.
AFAIK you only can use a shared Keychain to share data between two apps. Take a look here for that: How to share keychain data between iOS applications

But perhaps another proposal will help you out: We developed an iOS app using CoreData and the Ensembles Framework from Drew McCormack to use the iCloud Sync. (https://github.com/drewmccormack/ensembles)

With this feature (iCloud Sync) it is able to synchronize the data between both CoreData databases and both of your apps can use the same data.

Community
  • 1
  • 1
Bernd
  • 189
  • 9
-2

No you cannot access database in one app from another app.(Sandbox)

Because database is private to app.

Vikas Pandey
  • 550
  • 4
  • 13