开发者

Error while updating. 'attempt to write a readonly database

开发者 https://www.devze.com 2023-02-17 06:28 出处:网络
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.

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消