Sqlite Prepare Failed: No such table <table_name>
I am using Sqlite database in my iphone app.
Here in my app i initially used a absolute path like @"/Users/macos/Documents/appdatabase.sql
Now here I want to run the app on the device. It requires the relative path.
What needs to be done to get that path for the database ?
Here I am getting this error when i try t开发者_开发问答o run with the absolute path on the device.
Sqlite Prepare Failed: No such table
I have checked that table already exist in my database.
What should I do to get the relative path for the database?
Please Help and Suggest.
Thanks
You can get the database path using this -
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
NSString *databasePath = [documentsDir stringByAppendingPathComponent:@"mydb.sqlite"];
also delete your app from simulator or device and run/install it again.
精彩评论