I have been trying to get the URI path for an asset file.
uri = Uri.fromFile(new File("//assets/mydemo.txt"));
When I check if the file exists I see that file doesn't exist
File f = new File(filepath);
if (f.exists() == true) {
Log.e(TAG, "Valid :" + filepath);
} else {
Log.e(TAG, "InValid :" + filepath);
}
Can some one tell me how I can mention the absolute path for a file existing in the asset folder
Be sure ,your assets folder put in correct position.
Try out this : it works
if you have null value exception try this one:
TopBranData is a Class
Works for WebView but seems to fail on
URL.openStream()
. So you need to distinguish file:// protocols and handle them via AssetManager as suggested.Please try this code working fine
There is no "absolute path for a file existing in the asset folder". The content of your project's
assets/
folder are packaged in the APK file. Use anAssetManager
object to get anInputStream
on an asset.EDIT
To repair one of my comments below, the URL syntax for assets is
file:///android_asset/...
(note: three slashes).