Good morning.
I want to use the Android plug-in to save the image to Internal Storage and import the image from Internal Storage.
When you save an image in Unity, the user can access the saved image. I do not want users to access stored images. So I tried to create and use Android plugin, but it is not working properly.
I need help.
Android Native Code :
public void WriteToInternalStorage(String name, byte[] data) {
    try{
        FileOutputStream fileOutputStream = context.openFileOutput(name, context.MODE_PRIVATE);
        fileOutputStream.write(data);
        fileOutputStream.close();
    } catch(IOException e) {
        e.printStackTrace();
    }
}
public byte[] ReadToInternalStorage(String name) {
    StringBuffer stringBuffer = new StringBuffer("");
    byte[] buffer = new byte[1024];
    int n;
    try {
        FileInputStream fileInputStream = context.openFileInput(name);
        InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8");
        BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
        String line;
        while((line = bufferedReader.readLine()) != null) {
            stringBuffer.append(line);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return  String.valueOf(stringBuffer).getBytes();
}
Unity Code :
public void NativeCall_ReadInternalStorage(string name)
{
    byte[] test = instance.Call<byte[]>("ReadToInternalStorage", name);
    Texture2D tex = new Texture2D(2, 2);
    tex.LoadImage(test);
    Thumbnail.texture = tex;
}
The image is not displayed properly. I do not know what's wrong with the Android native code.
Please help me.
