views:

171

answers:

1

Hi,

I noticed that now and then my app can't find my database sqlite file anymore. It copies a new one and i am left with an empty database. I also noticed sometimes it switches to a previous database file, and i suddenly see data i filled in another time.

I think and hope this has something to do with the iPhone Simulator and not with my app?

Anyone experienced similar issues?

Thanks, Bjorn

+1  A: 

Yes I have also experienced similar issues, this is exclusive to the iPhone simulator. As I have never had this problem in the device, yet it seems to happen every so often in the simulator.

What happens is that for some reason the when you re-install the application on the simulator sometimes it will create a new folder (instead of using the previously created one), and therefore it will create a new database. The other database is still there in the previously created folder, it is just not pointing to it anymore. However why this happens is still a mystery to me.

These folders are located at /users/yourname/Library/Application Support/iPhone Simulator/Users/Applications. You will notice that there are one or more folders named something like 64631A5F-8914-4449-9453-A773C790B1DB one of this folders corresponds to the application you are running right now, you will notice that there are 2 folders that are really the same application, but one contains the previous sqlite Database (in the documents Directory) and the other has the newly created sqlite Database.

Hope that is clear.

-Oscar

OscarMk
This is true, and it is annoying. Sometimes I install and my data is gone, so I create some more test data. It works for a while, and then I install again a few hours later and all the data that I previously lost is suddenly restored and I lost all my data that I had only seconds before. It's like it sot of randomly toggles between 2 installation directories.Very annoying, but purely a simulator bug and you don't need to worry about on a device.
Squeegy
I've never detected any sort of pattern (other than "at the worst possible times"), but one can save a lot of headaches by deleting the old directories. It helps for a while
justin