My app has .txt files in subdirectories in the assets folder. It reads those .txt files and puts them in a textview. It\'s working great and no problems.
Should I be
if you really want to check for the file existence:
AssetManager mg = getResources().getAssets();
InputStream is = null;
try {
is = mg.open(pathInAssets);
//File exists so do something with it
} catch (IOException ex) {
//file does not exist
} finally {
if (is != null) {
is.close();
}
}
If your file is located in assets/folder/file.ext
, then pathInAssets
would be
"folder/file.ext"