webview can't access local files?
Hello everyone!
I tried to use webview to load local html file
(for convenience, I modified sample project ApiDemos ./development/samples/ApiDemos
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.webvi
final String mimeType = "text/html";
final String encoding = "utf-8";
WebView wv;
try {
InputStream is = getAssets().open("HelloWorld.h
int size = is.available();
// Read the entire asset into a local byte buffer.
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
// Convert the buffer into a string.
String strContent = new String(buffer);
wv = (WebView) findViewById(R.id.wv1);
wv.loadData(strContent, mimeType, encoding);
} catch (IOException e) {
// Should never happen!
throw new RuntimeException(e);
}
}
HelloWorld.html & HelloWorld.css is saved in folder : ./ApiDemos/assets
@import "HelloWorld.css";

Hello, World!
After startup the emulator, I pushed default.png in to folder /data/data/com.example.android
But when I run ApiDemos->View->WebView,
D/WebCore ( 216): Console: Not allowed to load local resource: file:///data/data/com.example.
So, what's the proplem?
Golden cherubim prada tote bag 2012 the border of yellow, green hand wan xia ROM peony mist the yarn
Yeah thanks for resolving this issue. now the problem is solved.
Regards
Ron H.
it is sometimes world of hard to Pandora in a world of adults Pandora Bracelets
I put all the HTML related files under folder "/$path of your application$/assets/"
and then, I replace function "loadData" with "loadUrl" , and it does work!
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.webvi
final String mimeType = "text/html";
final String encoding = "utf-8";
WebView wv;
wv = (WebView) findViewById(R.id.wv1);
wv.loadUrl("file:///android_a
}
New tutorials from Helloandroid
Recent Apps
Android on Twitter
-
@Lysha_74 (Lysha_74)I've completed San-Francisco Gifts quest in Airport City!
http://t.co/MQ0LDJrK #android #androidgames #gameinsight15 min 11 sec ago -
@Tuespaulsen (Tuesday Paulsen)Start playing Paradise Island on Android http://t.co/Onz6WIPP #Android #Androidgames http://t.co/FPlv37bN
15 min 12 sec ago -
@TecherrataFiles (Techerrata.com D/Ls)cm-9-encore-20120517-0700-unofficial.zip nightly is up. http://t.co/q9b1KLGy #cyanogenmod #cm9 #teamwin #android Q http://t.co/yHfc48oU
15 min 16 sec ago -
@amrsliem2 (amrsliem)Hurray! I've completed a "Ecology and Health" task! 6 http://t.co/ACHWaBoB #android #gameinsight #androidgames
15 min 17 sec ago -
@CM_Encore (CM Encore)cm-9-encore-20120517-0700-unofficial.zip nightly is up. http://t.co/EYBF8d5i #cyanogenmod #cm9 #teamwin #android Q http://t.co/HN6be9Tb
15 min 18 sec ago
Poll
Useful resources
Android Development Projects
- Mobile App Development by tinashe85
- Android Game - Money or snake by Abhi77
- Medical Flash Card App by ocnnor
- IPhone, IPad, Android App by digitekdesigns
- Google Play Android Developer Account by Hazen328
- Politics Mole Mash by justmart
- drawing party by lewisadelois
- iPhone / Youtube Application by chui12
- Wifi autoconnect service by wrochovina
- Android music player with radio by Lominero


you solve this issue very well.The following article actually established my very own little brown eyes towards the several merchants which usually organizations currently have by means of internet marketing.i like to read informative blogs and this blog is also so good and helpful.thanks for taking time to discus this topic..
ARY Musik