I'm trying to get a file in the assets
but when I run my code the FileNotFound
exception throws. I've checked with getAssets().list(".")
and really the android does not detect the file in the assets
directory, but i put the file in the assets
folder. I'm not a android expert and I count with the community help to help me to understand what am I doing wrong.
Follow bellow my code:
try {
Log.i("PEDRO", Arrays.toString(getResources().getAssets().list(".")));
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Result: []
try {
Log.i("PEDRO", Arrays.toString(getApplicationContext().getAssets().list(".")));
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Result: []
The file is in the assets
directory.
try {
InputStream input =
Definitions.appContext.getAssets().open("iot.neo..........com.bks");
} catch (IOException e) {
e.printStackTrace();
}
I know that is too much important to use the Android Studio
for the development of the applications, but I'm doing it on eclipse because it's a legacy code that will be changed to Android Studio
before (and I'm not a responsible for that).
Thanks a lot!
答案 0 :(得分:2)
Try remove ".":
try {
Log.d("PEDRO", Arrays.toString(getApplicationContext().getAssets().list("")));
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}