Ian Vink
Ian Vink

Reputation: 68750

Android Assets - Unable to access

Using this code it should return a list of the assets. But it crashes, with a "Source not found, Edit Source Lookup Path..." message in the debugger when I call the list method:

    @Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    AssetManager assets = this.getAssets();
    try { 
         //error happens on this next line
        String[] l = assets.list(null);
    } catch (IOException e) {

    }

}

Upvotes: 0

Views: 2175

Answers (2)

yanchenko
yanchenko

Reputation: 57156

Use this instead:

String[] arr = getAssets().list("");

Upvotes: 2

adamp
adamp

Reputation: 28932

Try passing a path to AssetManager#list(String) instead of null.

Upvotes: 1

Related Questions