Error while updating. 'attempt to write a readonly database
HI
I am using sqlite database. I know after application crash or system crash database get locked..
How I avoid to get my sqlite db locked.
How does I check that database lock during DML queries.
How does I open locked database.
Thanks
Mandeep
following is My Code.
NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"MyApp.sqlite"];
return defaultDBPath;
Now I changed above code to this.
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUs开发者_高级运维erDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
databasePath = [documentsDir stringByAppendingPathComponent:databaseName];
Many examples of using SQLite in Cocoa apps mention the approach of storing an empty "template" database copy as a resource within the application bundle. It's important to note an app bundle is not supposed to be writable, so this approach requires you copy the template to a writable location (use the standard storage locations, please) and use that file as your writable copy.
Could this be your problem?
精彩评论