Android: check file in app

I have several html files in the resource folder of my application. My application downloads these files depending on the language of the device. When I check for the existence of the file he is talking about, it does not exist, but when I download this file using browser.loadUrl (file name), it loads it in order.

The following code will help you 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);

[he loads newfile.html, but not actualfilename.html]

+3
source share
2 answers

You cannot use Filefor resources. For this you need to use AssetManager.

( , File , , , URI, , URI.create(). ( String) , URI.)

+2

, ? , , f.exists() not filename.exist().

: AssetManager . , , , , .

+1

All Articles