I want to hide the snap taken from the Camera application of device and save it in local storage so that it will not seen in Gallery or any other photo media sharing application.
I had done that part. But in file explorer I can see my snaps at address /storage/emulated/0/Android/data/<package name>/files**
directory. Fine with it too.
The problem I am facing is to make that un-readable, for that I converted the bitmap into byteArray and write that array into a file at the same directory.
int bytes = byteSizeOf(myBitmap);
ByteBuffer buffer = ByteBuffer.allocate(bytes); //Create a new buffer
myBitmap.copyPixelsToBuffer(buffer); //Move the byte data to the buffer
byte[] byteArray = buffer.array();
FileOutputStream fileOuputStream = new FileOutputStream(path);
fileOuputStream.write(byteArray);
fileOuputStream.close();
When I am reading this file and converting it to byteArray, I am getting same byte array but when I am decoding this byteArray to Bitmap, I am getting an bitmap as null
and following is showing in Logcat SkImageDecoder::Factory returned null
I am using following code to retrieve the Image bitmap
File f = new File(path);
try {
byte[] byteArr = FileUtils.readFileToByteArray(f);
Bitmap bmp;
bmp = BitmapFactory.decodeByteArray(byteArr, 0, byteArr.length);
addScrollchild(bmp);
} catch (Exception ex) {
}
I am getting null in bmp instance.
Any help will be appriciated.