How to read yaml model for opencv.face.FaceRecognizer in Android

In MainActivity.java I have included “import org.opencv.face.FaceRecognizer”.
My yaml file is stored under res/raw. The file is then copy to a new folder has a directory root.
I tried to get the model by FaceRecognizer.read(root)
I also tried FaceRecognizer.load but it does not exist.
My error message: java.lang.NullPointerException: Attempt to invoke virtual method ‘void org.opencv.face.FaceRecognizer.read(java.lang.String)’ on a null object reference
What should I do?

My code:

protected void faceLoad() throws IOException {
InputStream is2 = getResources().openRawResource(R.raw.test);
File cascadeDir2 = getDir(“cascade”, Context.MODE_PRIVATE);
cascFile2 =new File(cascadeDir2,“test.yaml”);
String root;
root = cascFile2.getAbsolutePath();
FileOutputStream fos2 = new FileOutputStream(cascFile2);

        byte[] buffer2 = new byte[4096];
        int bytesRead2;

        while ((bytesRead2 = is2.read(buffer2)) != -1){
            fos2.write(buffer2,0, bytesRead2);
        }

        is2.close();
        fos2.close();


        faceRecognizer.read(root);

}