Home:ALL Converter>Can I send/receive sqlite Database by Airdrop

Can I send/receive sqlite Database by Airdrop

Ask Time:2014-09-15T14:46:51         Author:RegularExpression

Json Formatter

Is it possible to use Airdrop to send/receive a sqlite database (single file .sqlite) used by my app from one iPad to another? If so, how to I get to the file on the receiving device?

If not, what is the best option, from within an app, to send a file to the same app on a different device? Files will always be a sqlite database.

Author:RegularExpression,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/25842255/can-i-send-receive-sqlite-database-by-airdrop
RegularExpression :

In case anyone stumbles onto this, the answer is YES, you it can be done. I'll outline the approach I took.\n\nFirst, I used a separate Core Data stack to create the sqlite file to be exported (in my case with some filtering, etc.), then renamed the sqlite on the sending device to have an extension that is unique to our app. Then, the following code is used to initiate the transfer:\n\nNSURL *url = [coreDataExporter urlToShare];\nUIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:[NSArray arrayWithObject:url] applicationActivities:nil];\n\n// Exclude all activities except AirDrop.\nNSArray *excludedActivities = @[UIActivityTypePostToTwitter, UIActivityTypePostToFacebook,\n UIActivityTypePostToWeibo,\n UIActivityTypeMessage, UIActivityTypeMail,\n UIActivityTypePrint, UIActivityTypeCopyToPasteboard,\n UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll,\n UIActivityTypeAddToReadingList, UIActivityTypePostToFlickr,\n UIActivityTypePostToVimeo, UIActivityTypePostToTencentWeibo];\ncontroller.excludedActivityTypes = excludedActivities;\n\n// Present the controller\n[self presentViewController:controller animated:YES completion:nil];\n\n\nUse this link to set up your unique extension so it is recognized as a file belonging to your app:\n\nhttps://developer.apple.com/library/ios/qa/qa1587/_index.html\n\nYou pretty much use that link as-is but substituting your own description, identifier, and extension. Much easier than some of what you'll find looking around the Internet. Takes five minutes.\n\nOnce the transmission completes on the sending device, the file will reside in the Documents/Inbox directory as a read/delete only file. The App Delegate can implement the following method:\n\n\n(void)applicationDidBecomeActive:(UIApplication *)application\n\n\nto copy the file wherever you need it on the receiving device. When the file is received on the receiving device it will know to start your app to process it and the DidBecomeActive will fire allowing you to handle it however you need to.\n\nAlso, you can use:\n\n\n(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation\n\n\nin the app delegate to post a notification so that if the app is already active (thus DidBecomeActive doesn't fire) your app can listen for the notification to take appropriate action.\n\nIt has been a pretty long slog to figure this out. Hopefully, posting this summary here will help someone down the road.",
2014-09-18T06:58:01
yy