qlabfgerkaSmurf
qlabfgerkaSmurf

Reputation: 396

Android Studio path to XML resource

So im using OpenCV and i need to get a path to an XML file. How do i do that. Im using Android Studio Java. The code looks like this:

CascadeClassifier face = new CascadeClassifier("../../../res/xml/haarcascade_frontalface_default.xml");

Location of the class:

/Users/me/Desktop/a/b/c/app/src/main/java/com/me/projekt_app/Camera.java

Location of the XML:

/Users/me/Desktop/a/b/c/app/src/main/res/xml/haarcascade_frontalface_default.xml

Upvotes: 1

Views: 425

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006724

Resources are files on your development machine. They are not files on the device.

You can either:

  • Put the XML in assets/, then use AssetManager to open an InputStream on the XML and use that to write the XML to some file; or

  • Put the XML in res/raw/, then use Resources to open an InputStream on the XML and use that to write the XML to some file

Upvotes: 2

Related Questions