1

I have a project that I am working on that requires me to be able to display an HTML file stored in a SQLite database in a uiwebview. I know how to display a local file stored in the main bundle, but I just can't figure out how to get these files stored in the SQLite database to display in the uiwebview. If anyone can help me it would be greatly appreciated. Sample project or tutorial is great! Thanks in advance!

ADDED INFO I thought I would attach this link to help in understanding what I'm trying to do. http://www.google.com/url?sa=t&source=web&cd=1&ved=0CCYQFjAA&url=http%3A%2F%2Fdblog.com.au%2Fiphone-development-tutorials%2Fiphone-sdk-tutorial-reading-data-from-a-sqlite-database%2F&rct=j&q=sqlite%20animals%20tutorial%20iphone&ei=41eIT-79L9H-2QW50tXaCQ&usg=AFQjCNGqongc81oHHa3WGFTctkBIiduCvA in the linked tutorial I have dropped the image view since I don't need it for my purposes, and I have replaced the data in the database to be the contents of an html file. In the tutorial it displays the text in a textview and I want to change it to display in a uiwebview. I want this to keep formatting and a few other reasons. Thanks to those who have posted. If anyone can help me get this it would be great!! Thanks in advance!

1
  • I add more info to my question to make easier to answer. Thanks to all. Commented Apr 13, 2012 at 17:11

3 Answers 3

2

webView loadHTMLString:baseURL: (I assume it is just stored as a string....if you have any images, you will need to set your base directory accordingly)

Sign up to request clarification or add additional context in comments.

Comments

1
  [WebView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"test" ofType:@"html"]isDirectory:NO]]];

this code displays "test.html" which is located in the project folder

3 Comments

I know how to do that. I'm trying to display a file stored in a SQLite database.
so u want to know how to access a file from SQLite
Yes. I'm trying to access the file and then display it in a uiwebview. It is an HTML file.
1

Got it by using

NSString *html = [animal description];
[self.animalView.animalDesciption loadHTMLString:html baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];

when the ViewController that contains the webview is pushed into the display.

3 Comments

How does this answer involve SQLite at all?
check out the link to the tutorial and you will see what how it is changed by the above code.
No thanks...no one wants to read a tutorial to get an answer to a question

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.