Sanju ju Sanju ju - 7 months ago 48
iOS Question

Unable to see SQLite file in iTunes

- (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:

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 ?


You are not creating the file in the Documents directory, but the Library directory:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
//                                                   ^^^^^^^^^^^^^^^^^^

You want NSDocumentDirectory.