简体   繁体   中英

Assets @ Android

I am having problems listing assets in my apk file, my aim is to be able to get the direct path of one of my assets and pass it to native code using JNI
1. I have added a file to the assets folder of my project
2. I have verified that the file exist in the '/assets' folder of the apk file resulting of compilation of my project
3. at the 'onCreate' function of my Activity I do the following:
AssetManager am = this.getApplicationContext().getAssets();
String strAssets[] = am.list("/assets");
4. strAssets.length is always zero
5. I was getting the same for "./assets" and "assets"

What am I doing wrong here? why can't I list the available assets?

Any help will be appreciated.

~Nadav at sophin

am.list("/assets") lookes for a folder called 'assets' within your assets folder. Just use am.list("") to get all files.

The argument to the list method is the path within the assets folder. if it's at the root, shouldn't you get results from either an empty string or a single slash?

AssetManager.list(String path)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM