I have few html files in assets folder of my application. My application loads these files depending on the device language. When I check for the existance of the file it say does not exist, but when I load that file using browser.loadUrl(filename), it loads it fine.
Following code will help you to understand my problem:
String filename="file:///android_asset/actualfilemname.html";
File f = new File(filename);
if(!f.exist){
filename = "file:///android_asset/newfile.html";[Everytime it loads this file even though I have actualfilename.html in the folder]
}
browser.loadUrl(filename);
[it loads the newfile.html but not actualfilename.html]
You can’t use
Filefor resources. You’ll need to use theAssetManagerfor that.(In the off-chance that
Filedoes handle resources, which I don’t think it does, you’ll have to convert the path to aURIfirst, for example usingURI.create(). File(String) expects a path, not a URI.)