Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid: how to load xml file from assets directory?
    primarykey
    data
    text
    <p>i have trouble loading an xml file from assets directory. using the same line of code (just changing the path) i get different results ( either ok or NPE / file corrupted ) the file "castle1.tmx" (it's an xml file) is copied in two locations:</p> <ul> <li>res/xml/castle1.tmx</li> <li>assets/level/castle1.tmx</li> </ul> <p>with this line, it works:</p> <pre><code>XmlResourceParser xrp = ctx.getAssets().openXmlResourceParser("res/xml/castle1.tmx"); </code></pre> <p>while with this line it doesn't:</p> <pre><code>XmlResourceParser xrp = ctx.getAssets().openXmlResourceParser("assets/level/castle1.tmx"); </code></pre> <p>i get the following result:</p> <pre><code>04-05 21:46:40.940: WARN/ResourceType(29056): Bad XML block: header size 28024 or total size 1702240364 is larger than data size 70441 04-05 21:46:40.940: ERROR/TestParser(29056): Unable to read resource file 04-05 21:46:40.940: WARN/System.err(29056): java.io.FileNotFoundException: Corrupt XML binary file 04-05 21:46:40.940: WARN/System.err(29056): at android.content.res.AssetManager.openXmlAssetNative(Native Method) 04-05 21:46:40.944: WARN/System.err(29056): at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:485) 04-05 21:46:40.944: WARN/System.err(29056): at android.content.res.AssetManager.openXmlResourceParser(AssetManager.java:453) 04-05 21:46:40.944: WARN/System.err(29056): at android.content.res.AssetManager.openXmlResourceParser(AssetManager.java:442) 04-05 21:46:40.944: WARN/System.err(29056): at game.test.MapLoader.&lt;init&gt;(MapLoader.java:73) </code></pre> <p>file is found in both case... it's just that i cannot seem to be able to read it from asset dir using that method..</p> <p>any ideas how can i load my xml file from assets directory ?</p> <p>tnx</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload