is there any way to have an html file (i.e. an html template) be a resource in android? I'd like to reference it in a similar way that i store strings in the res/values/strings.xml. However, when i do this, it appears the HTML is not getting rendered correctly when i use myTextView.setText(Html.fromHtml(MessageFormat
.format(getResources().getString(R.string.myHtmlFile), ...)
views:
53answers:
1
+1
A:
Hi,
You can place raw HTML or other format files in /res/raw or /assets directory of your project. You can access the first with this method, and the second with this.
ognian
2010-06-28 16:05:35
so this works, but then i have to go thru the pain of using an input stream. is there a simple way that you know of to just get the contents of a file into a string? in C#, you can just say `String blah = new StreamReader(myInputStream).readToEnd()`isn't there anyway to do that in android/java?
Ben
2010-06-28 17:20:23
Write a static method somewhere that takes InputStream and returns a String. Wrap the stream with BufferedInputStream, and append the data to a StringBuilder until exhausted.
ognian
2010-06-28 18:13:31
blech. i hate re-inventing the wheel, i added a ref to apache.commons.io thanks though... :)
Ben
2010-06-28 18:23:49