Problem
On iOS, when no App Group is configured, the library stores databases in the app's Documents directory:
https://github.com/margelo/react-native-nitro-sqlite/blob/main/packages/react-native-nitro-sqlite/ios/OnLoad.mm
// Get iOS app's document directory (to safely store database .sqlite3 file)
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true);
documentPath = [paths objectAtIndex:0];
The Documents directory is exposed to users via the Files app (and iTunes/Finder file sharing) whenever the app enables UIFileSharingEnabled + LSSupportsOpeningDocumentsInPlace. That means users can see, share, modify, or delete the raw SQLite database (and its -wal/-shm journals) from outside the app — which is both a data-integrity and a data-exposure problem.
Apple's File System Programming Guide is explicit that Documents is for user-visible documents, while app-internal data files belong in Library/Application Support (persistent, backed up, never user-visible).
Proposal
Store databases in Library/Application Support instead of Documents, and migrate existing databases out of Documents so current users don't lose data.
At Expensify we hit this in production and currently ship a patch that does exactly this (including a careful migration that moves the database together with its -wal/-shm files, and falls back to the old location if the move fails): Expensify/App#96531
Happy to upstream this — PR incoming.
Problem
On iOS, when no App Group is configured, the library stores databases in the app's Documents directory:
https://github.com/margelo/react-native-nitro-sqlite/blob/main/packages/react-native-nitro-sqlite/ios/OnLoad.mm
The Documents directory is exposed to users via the Files app (and iTunes/Finder file sharing) whenever the app enables
UIFileSharingEnabled+LSSupportsOpeningDocumentsInPlace. That means users can see, share, modify, or delete the raw SQLite database (and its-wal/-shmjournals) from outside the app — which is both a data-integrity and a data-exposure problem.Apple's File System Programming Guide is explicit that Documents is for user-visible documents, while app-internal data files belong in
Library/Application Support(persistent, backed up, never user-visible).Proposal
Store databases in
Library/Application Supportinstead ofDocuments, and migrate existing databases out of Documents so current users don't lose data.At Expensify we hit this in production and currently ship a patch that does exactly this (including a careful migration that moves the database together with its
-wal/-shmfiles, and falls back to the old location if the move fails): Expensify/App#96531Happy to upstream this — PR incoming.