Hello i´m working on a project with sqlite and FMDB. Everything works fine. But if i´m removing the old database and adding a new one the iphone does not recognize that there is a new database. It still works with the old database.
It works if i remove the app from the simulator and clean the project. But that is not a good solution.
Does anyone can tell me how i can replace the database so that the device recognize it.
If your want to completely drop the sqlite database file from your application you can call the below line before initialising the new database.
[[NSFileManager defaultManager] removeItemAtPath:[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"<your db with extention>"]] error:NULL];
The Sqlite database is a single file in your app, what the above code is doing is deleting that file from the app which is located in the 'Document Directory' of your app. So if you want to delete the previous database just call that line before calling FMDatabase *db = [FMDatabase databaseWithPath:@"<your db with extention>"];