SQLite Error deny file-write-create -
Help solve the problem when you start the emulator, there is no problem when the app on the device does not work An error occurs if:
Sandbox: Mapimage files write / private / var / mobile / applications / 3547CCCF Disclaimer -7 A0D-4C01-AA41-18D72C686314 / MAPOSM.app / maps / St.sqlite
Writing permission works on the database file only if the file is a document directory Be added Holder. Then first create the file in the document folder and then restart
- (zero) check and CREATEDATE database {// Check that if the SQL database is already saved in users' phones then Do not copy it on BOOL success; // Create a file manager object, we will use it to check the database status // and if it is necessary to copy it, NSFileManager * fileManager = [NSFileManager defaultManager]; // Check that the database has already been created in user file system success = [fileManager fileExistsAtPath: _databasePath]; // If the database already exists, if (success) returns, then return without anything; // If not, copy the file system from the users to copy the file from the database / get the path to the database in the application package NSString * databasePathFromApp = [[[NSBundle mainBundle] resourcepath] stringbappingpath company: _databaseName]; Copy the database file system from the // package [fileManager copyItemAtPath: databasePathFromApp toPath: _databasePath error: zero]; } // ----------------------------------------------- -------------------------------------------------- ---- // #pragma Icon - Supporting methods // ------------------------------------ -------------------------------------------------- --------------- // - (BOOL) successfully dbOpened {if (sqlite3_open ([[self dbPath] UTF8String], & amp; _database) == SQLITE_OK {return yes; } And {{[[UILertview Alok] Init Vitalit: @ "Error" Message: @ "Error opening DB" Representative: Cancel yourselfTuitamental: @ "OK" Other button: Titles: zero, zero] show]; no return; }} // ---------------------------------------------- -------------------------------------------------- ----- // #pragma mark - query // ------------------------------------ -------------------------------------------------- --------------- // - (zero) executeQuery: (NSString *) structure {char * error = NULL; If ([successfully dBopense itself]) {NSLog (@ "% @", Structure); Sqlite3_exec (_database, [strQuery UTF8 string], zero, zero, and error); If (error! = Zero) {NSLog (@ "% s", error); } Sqlite3_close (_database); }}
Comments
Post a Comment