0
I have a method that is part of a class to capture the client’s signature.
But he’s giving trouble when it comes to opening the FileOutputStream
, appears "No such file or directory"
follow the method:
/**
*
* @param MEDIA_DIRECTORY ex: /storage/emulated/0/appname/assinaturas-consultas/
* @param STOREDPATH ex: /storage/emulated/0/appname/assinaturas-consultas/teste.png
* @return
*/
public boolean save(String MEDIA_DIRECTORY, String STOREDPATH) {
view.setDrawingCacheEnabled(true);
if (bitmap == null)
bitmap = Bitmap.createBitmap(640, 480, Bitmap.Config.RGB_565);
Canvas canvas = new Canvas(bitmap);
view.draw(canvas);
try {
File storageDir = new File(MEDIA_DIRECTORY);
if (!storageDir.exists())
storageDir.mkdirs();
FileOutputStream out = new FileOutputStream(STOREDPATH); //Erro acontece aqui.
view.draw(canvas);
bitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
out.flush();
out.close();
return true;
} catch (Exception e) {
Log.e("log_tag", e.toString());
}
return false;
}
I’ve also put these two lines on Manifest
:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />