im developing uiwebview in my app.
this UIWebView displays HTML5 pages and has javascript which access local db and displays lists of menu.
Problem is that i need to copy this database from app’s document directory and paste it to safari/databases folder..so that my javascript file can access this db and display list of files.
however no success in copying file from document folder to safari/Databases folder
here is my code:
NSString *databasepath=[NSString stringWithFormat:@"~/Library/%@/%@",@"safari",@"databases"];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSString *resourcePath = [[NSBundle mainBundle] pathForResource:@"sfa.db" ofType:nil];
[fileManager copyItemAtPath:resourcePath toPath:databasepath error:&error];
Any help will b appreciated.
Thanks in advance.
Thanks for all of ur replies. although it doesnt solve my problem..
1) I want javascript to connect with existing sqlite3 database located in my app’s document directory.
2) but OpenDatabase() method always points to safari/databases directory
3) either i get a way to b able to point document directory in OpenDatabase() method
OR
some other way to keep a copy of my sqlite3 database from my app’s document directory to Safari/Databases
OR
any other way to solve this problem.
I solved my problem using function stringByEvaluatingJavaScriptFromString
here is my code:
in my model:
in my html