LuxuryMode
LuxuryMode

Reputation: 33741

accessing file from assets

I've tried File file = new File("file:///android_asset/something.xml") and it doesn't seem to work. It worked when I tried loading up html in a webview, but won't work when I'm trying to get at an xml file I've stored there so I can parse it with DocumentBuilder.

What gives? I'm guessing I can't access a file like that.

Here's the Exception: java.io.FileNotFoundException: /file:/android_asset/something.xml (No such file or directory)

Is it escaping out some of the slashes? if so, how do I get 'em back?

Upvotes: 1

Views: 1539

Answers (1)

Benny Tjia
Benny Tjia

Reputation: 4883

I have noticed that there is a similar problem I had in the past. You have to use Activity.getAssets().open(...) as you cant create instance that way in android environment. Here is the link to the forum that helped me solve my problem. Hope it helps, let us know if that works.

Upvotes: 2

Related Questions