First App Update, User Data Lost (Was Stored in Documents Directory)

After iOS 5 update, files in my document directory are gone? Is iOS changing the documents directory?

It's difficult to answer your question without mor information. The fact that you are able to read the sqlite file which you say is in the Documents folder indicates that your program can at least find that file.

You can look and see what exactly is in the Documents folder by setting the
Application Supports iTunes file sharing
attribute in the Application's info.plist file. You can then view the Application's Documents folder and add/remove files in iTunes.

You can also look in the

~Library/Application Support/iPhone Simulator/<IOSVERSION>/Applications/<UUID>/Documents

directory if you are running the simulator.

You will at least know what the actual contents of the Documents directory are...

While updating the Application all local files are deleted in iPhone

Don't save the entire path into sqlite,just save the file name which you are stored in local so while fetching, get the current directory path and append with fileName from sqlite. This will solve when you upgrading your app also.

Any possibility of directory change when update app?

I found that updating app causes directory changed.

So should not save 'Full Path' at Database or file.

Where to store private important user data when the Documents directory is not an option?

I've seen Library/Preferences (where NSUserDefaults are stored) be kept across restores, so I think most of Library is kept. The cache directories are probably excluded, though.

In general, just use the APIs to fetch paths and trust that iTunes will preserve them unless they're meant to represent temporary folders. That means you should use a subdirectory of your NSApplicationSupportDirectory named for your application:

NSArray * urls = [[NSFileManager defaultManager] URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask];
NSAssert([urls count], @"Can't get app support directory");

NSURL * url = [urls objectAtIndex:0];
url = [url URLByAppendingPathComponent:@"MyAppName"];

In practice, this will end up being "Library/Application Support/MyAppName" in your sandbox, but you should use the API anyway to ensure this is kept future-proof.

(If you care about support for iOS 3 or 2, use the NSSearchPathForDirectoriesInDomains() function instead of the -URLsForDirectory:inDomains: method.)

Updated app will remove existent files

No, your user's data will not be lost when updating the app if it is stored in the Documents directory.

The only time this data will be lost is if the user deletes the application of if the user resets his/her phone.



Related Topics



Leave a reply



Submit