- (void) copyDatabaseIfNeeded
{
BOOL success;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:ABC.Sqlite];
success = [fileManager fileExistsAtPath:writableDBPath];
if (success) return;
// The writable database does not exist, so copy the default to the appropriate location.
NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:ABC.Sqlite];
success = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&error];
if (success)
{
NSURL *url=[NSURL URLWithString:WSURL2];
} else
{
NSLog(@"Failed to create writable database file with message '%@'.", [error localizedDescription]);
}
}
I need to add any code for to View Sqlite File ??
I tried by adding these in Plist: UIFileSharingEnabled
, CFBundleDisplayName
How can i view my SQLIte file in iTunes ?
Referred links:
How to enable file sharing for my app?, UIFileSharingEnabled has no effect
If i enabled iTunes file sharing option in my app to backup app data in PC, will appStore rejects the app ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…