jeudi 29 janvier 2015

App force close clearing up SQLite entries

I have created SQLite db using following approach. When user first login I insert few records to this DB. On subsequent logins I use this information for further processing. This is working fine as long as user don't force close app using approach described here.


If user force close and login to app again, all the information he/she entered was lost. Now my question is, how can I make sure "force close" won't wipe out my data? Any help appreciated.



// Get the path to the documents directory and append the databaseName
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex: 0];
NSFileManager *fileManager = [NSFileManager defaultManager];

filePath = [documentsDir stringByAppendingPathComponent: @"mydb.db"];

// If the database already exists then return without doing anything
if (![fileManager fileExistsAtPath: filePath])
{

//Create db code.

}

Aucun commentaire:

Enregistrer un commentaire