I would like to get the filesize of a file located in the assets directory. I saw many examples like
InputStream myInput = appContext.getAssets().open()
I know i can determine filesize by simple reading InputStream in cycle but I'm looking for a way to do this via File object.
So i need a path to assets and thats the thing i can't determine... How to get that path?
Also tried getting AssetFileDescriptor via appContext.getAssets().openFd() and openNonAssetFd() but no luck - got FileNotFound or probably compressed exceptions.
BTW those openFd methods are "pretty described" at developer.android.com.
I'd tried next code:
file = new File(new URI("file:///android_asset/db/call3.db"));
Log.i(APP_TAG, "File name: "+file.getName());
Log.i(APP_TAG, "File path: "+file.getPath());
Log.i(APP_TAG, "File length: "+file.length());
Log.i(APP_TAG, "File isFile: "+file.isFile());
Log.i(APP_TAG, "File exists: "+file.exists());
which outputs to log:
04-13 12:10:03.413: INFO(6259): File name: call3.db
04-13 12:10:03.432: INFO(6259): File path: /android_asset/db/call3.db
04-13 12:10:03.444: INFO(6259): File length: 0
04-13 12:10:03.444: INFO(6259): File isFile: false
04-13 12:10:03.444: INFO(6259): File exists: false
of course the size of file is not 0 it is 195 584 bytes.