Trying to do this code
try {
if(!file.exists()){
file.createNewFile()
file.exists()
}
val out = FileOutputStream(file)
finalBitmap.compress(Bitmap.CompressFormat.JPEG, 100, out)
out.flush()
out.close()
} catch (e: Exception) {
e.printStackTrace()
}
But getting
java.io.IOException: No such file or directory
Very strange behaviour
solved
val file1 = File(Environment.getExternalStorageDirectory().toString() + "/" + File.separator + "test.png")
file1.createNewFile()
file1.exists()
val out = FileOutputStream(file1)
finalBitmap.compress(Bitmap.CompressFormat.PNG, 100, out)
out.flush()
out.close()