0
votes

This tutorial told me i need to throw 3 files (in WAL mode) to the bundle.

https://www.appcoda.com/core-data-preload-sqlite-database/

MY app using DELETE WAL mode , only 1 file exist there (.sqlite only).

I just testing and throw just 1 file (.sqlite) to the bundle. Then write method to copy it to App's Document dir. It work :o , the file copied perfectly.

But i still wonder if 1 file mode would crash my app later ?? Should i switch to "3 files" mode (WAL MODE ) instead ???

update ***

Hi thanks alot , i just copied .sqlite file to NSBundle perfectly. But after i copied files from Bundle to Document directory. My PSC cant read the .sqlite (thought the ps added to psc perfectly , checked by [psc persistentStores] . Fetched Data still empty (thought i could see the data exists in .sqlite from DBBrowser) . I have tried this over and over but still nothing work (changing file name / etc ) .

My PSC option is like this . I wonder is this the cause ??? thanks

 @{    NSSQLitePragmasOption : @{@"journal_mode":@"DELETE"},
                     NSInferMappingModelAutomaticallyOption: @YES,
                      NSMigratePersistentStoresAutomaticallyOption :   @YES };    
1
As I explained in my answer to your previous question, no you do not need to create and copy these extra files. - Tom Harrington

1 Answers

0
votes

I assume that what you mean by

DELETE WAL mode

is that your database is in DELETE journaling mode.

As the SQLite doc states:

The DELETE journaling mode is the normal behavior. In the DELETE mode, the rollback journal is deleted at the conclusion of each transaction. Indeed, the delete operation is the action that causes the transaction to commit.

Conserning the shared memory file it says that it is only used

When operating in WAL mode [...]

So if the last connection to the DB was properly closed you should be fine. If you're still worried you can also verify the integrity of the DB by running

    PRAGMA integrity_check

or

    PRAGMA quick_check

on it.