I'm sorry, the correct path is "/data/data/com.alberto.autocontrol2/files" (taken from Android Studio's device explorer). And this is the code to take the photo from the camera and save it to the device storage. The code is taken from a separate "PantallaRegistrarVehiculo.kt" screen (VehicleRegistrationScreen.kt in English):
val lanzador = rememberLauncherForActivityResult(
contract = ActivityResultContracts.TakePicturePreview()
) { bitmap: Bitmap? ->
if (bitmap != null) {
val file = File(contexto.filesDir,
"${viewModel.listaVehiculos.value.size}.jpg") // Or .png
try {
FileOutputStream(file).use { out ->
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out) //
Or PNG
}
imageBitmap = bitmap.asImageBitmap()
} catch (e: IOException) {
e.printStackTrace()
}
}
}