Android cannot open file using LibGDX

I am currently writing a LibGDX game, and I need to open an XML file for a sprite. Unfortunately, when I try to open a file, I get IOException. Files exist in the right places, the project is cleaned and updated, etc.

Here's the kicker: LibGDX will open and display the image files in the same directory and actually get the XML file in its own object FileHandle(I had it logcat size and it matches). However, when I send the file to the SAX parser, I get an exception that returns me to the file, saying that it cannot open it.

Here's the problem of the line of code inside the class ClipSprite:

private void parseConfigFile(FileHandle file) throws ParserConfigurationException, SAXException 
{
    //Use a SAX parser to get the data out of the XML file.
    SAXParserFactory factory = SAXParserFactory.newInstance();
    SAXParser parser = factory.newSAXParser();
    XMLConfigHandler handler = new XMLConfigHandler();

    //Parse through the document
    try
    {
        parser.parse(file.path(),handler); //IOException here
    }

And here is the code in which I select the file in the game in the method createin the main LibGDX class

    //This loads a png file
    texture = new Texture(Gdx.files.internal("data/graphics/CDE1/CDE1.png"));
    texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);      
    TextureRegion region = new TextureRegion(texture, 0, 0, 512, 275);

     //Here I load the xml file and it tells me how many bytes it is
    Gdx.app.error("File","xml bytes:"+Gdx.files.internal("data/graphics/CDE1/CDE1.xml").length());

     //Here I load the same file and it crashes
     //Note that it looks in the subdirectory and finds /CDE1.xml properly
    animation = new ClipSprite("data/graphics/CDE1");

Logcat error:

java.io.IOException: Couldn't open data/graphics/CDE1/CDE1.xml

, IOExceptions , ? , .

+5
1

, , - - :

Gdx.files.local() Gdx.files.internal(), "" () APK "", . ( , , , .)

libGDX FileHandle file file.file(), file.path(), , .

libGDX FileHandle file file.read(), InputStream ( ).

libGDX Android AssetManager, bit wonky . , .jar .apk .

+8

All Articles