NadavRub
NadavRub

Reputation: 2610

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

Upvotes: 0

Views: 402

Answers (2)

user717572
user717572

Reputation: 3652

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

Upvotes: 1

Rich
Rich

Reputation: 36806

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)

Upvotes: 0

Related Questions