I created iPhone application using sqlite db. In this sqlite db I have stories document, directory images url, and other parameters. When the user is using the "lite" version of the app, everything works fine. But when I upgrade app from "lite" version to a "paid" version, I'd like to be able to copy database and latest files in my Documents
directory to the "paid" app. Assistance would be appreciated.

- 415,655
- 72
- 787
- 1,044

- 35
- 6
-
my problem is that when i upgrade my iPhone app new version from App Store then i got string data from sqlite database and i show in app but i didn't getting photos in document directory using photos url. Means problem is that after upgrading app app did not getting photos in document directory? – suhas.porchys Jul 09 '13 at 05:39
-
@TBlue my problem after upgrade app. I did not see only those images i was store in old version app but new add images it will show. Hope u can understand my pblm – suhas.porchys Jul 09 '13 at 06:36
2 Answers
If the data base in Documents directory then while updating your app iOS keep the old database.

- 4,227
- 4
- 28
- 42
-
In my app i am storing image urls in sqlite db and images store in document directory. When i was upgraded app then other contain fetch and show in app like image name, other parameter value but problem only images didn't show in app. – suhas.porchys Jul 09 '13 at 05:45
-
Hi I understand this scenario. The question is not clear about your concern. Please update or ask new question about this issue. – rakeshNS Jul 09 '13 at 05:57
Because of app sandboxing, you can't do precisely what you want, but there are a number of approaches:
Instead of separate pro version, only have a single version of the app, which offers an In App Purchase that enables certain features. See Convert the "lite app" to "pro app" within the application. Thus, this eliminates the need to import files/settings from one app to another.
You could implement separate custom URL scheme for both free and pro versions of your app to allow them to exchange limited amount of data via a URL. Thus, the pro app would probably, on the first time it's run, check to see if the lite app is installed, and if so, request data from it:
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; BOOL runAlready = [userDefaults boolForKey:kRunAlready]; if (!runAlready) { [userDefaults setBool:YES forKey:kRunAlready]; [userDefaults synchronize]; [self importDataFromLite]; } } - (void)importDataFromLite { NSURL *liteURL = [NSURL URLWithString:@"testapp-lite://getdata"]; // if we can open test app, then test app installed, so launch it, providing "getdata" request if ([[UIApplication sharedApplication] canOpenURL:liteURL]) { // Getting data from lite app [[UIApplication sharedApplication] openURL:liteURL]; } }
The lite version would obviously have to set up its Info.plist to register this custom URL scheme, and its app delegate would need to respond to this request for data, in turn calling a custom URL scheme of the pro app to send the data back:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { [[[UIAlertView alloc] initWithTitle:nil message:[url absoluteString] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show]; if ([[url absoluteString] isEqualToString:@"testapp-lite://getdata"]) { // I'm going to create URL from local NSDictionary, but you would presumably retrieve data from your model/database NSDictionary *dictionary = @{@"name" : @"Rob", @"age" : @"29"}; NSMutableArray *array = [NSMutableArray array]; [dictionary enumerateKeysAndObjectsUsingBlock:^(id key, NSString *obj, BOOL *stop) { [array addObject:[NSString stringWithFormat:@"%@=%@", key, [obj stringByAddingPercentEscapesForURLParameterUsingEncoding:NSUTF8StringEncoding]]]; }]; // now create the URL NSURL *proURL = [NSURL URLWithString:[NSString stringWithFormat:@"testapp-pro://data?%@", [array componentsJoinedByString:@"&"]]]; // if we can open pro app, then then do so, providing "getdata" request if ([[UIApplication sharedApplication] canOpenURL:proURL]) { NSLog(@"Opening pro app"); [[UIApplication sharedApplication] openURL:proURL]; } } return YES; }
In turn, the pro version could have custom URL scheme to receive the data from the lite version of the app. Thus, the pro app's handler for the data from the lite app might look like:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { NSArray *absoluteStringComponents = [[url absoluteString] componentsSeparatedByString:@"?"]; NSArray *parameters = [absoluteStringComponents[1] componentsSeparatedByString:@"&"]; for (NSString *parameter in parameters) { NSArray *parameterComponents = [parameter componentsSeparatedByString:@"="]; // I'm just logging the results, but you'd presumably integrate the results into your model NSLog(@"%@ is equal to %@", parameterComponents[0], [parameterComponents[1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]); } return YES; }
This works with modest amounts of basic data, but I would not have thought it would be well suited for exchanging image files. If interested, I can show you example of this.
In a variation of the above, you could use the UIDocumentInteractionController to import larger amounts of data, though I think this would request you to present a popover in the lite app for the user to specify to open the data file in the pro app (which seems inelegant).
You could, theoretically, store data on the cloud, possibly iCloud, DropBox, or your own server.
-
By the way, if you try to get "creative" and experiment with opening files from one app's sandbox from another's, note that only works on the simulator: As I recall, the simulator does not observe the app sandboxing rules that the devices enforces. Make sure to test your solution on actual devices. – Rob Jul 09 '13 at 07:26
-
If i'll use InApp Purchases but my problem is that lite and Pro application names are differ end then how to manage it? – suhas.porchys Jul 10 '13 at 07:17
-
@suhas.porchys If you're using IAP approach, there is only one application, not two separate applications (that's the entire purpose of employing IAP, to avoid having two applications; otherwise why bother implementing IAP?). I'm not sure if I'm following your question. – Rob Jul 10 '13 at 07:30