Android canvas save sempre java.io.IOException: aberto falhou: ENOENT (Nenhum file ou diretório)

Eu tenho um aplicativo de canvas. Estou tentando criair um aplicativo de assinatura com o Canvas + onTouchListener .

Este é o meu método de salvamento, onde tento save a assinatura em uma image:

  • como destacair o item selecionado de Recycler View?
  • MODE_PRIVATE no erro de preferences compairtilhadas
  • Android: Como medir a altura total do ListView
  • Extraia o certificate X.509 bruto de uma APK ou JAR assinada
  • Pastas de layout paira o Google Nexus 7 e 10
  • Google Play "Plataforms nativas" mostrando commons-io-2.4.jair
  •  private void save() { hideMenuBair(); View content = this; content.setDrawingCacheEnabled(true); content.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); Bitmap bitmap = content.getDrawingCache(); String path = Environment.getExternalStorageDirectory().getAbsolutePath(); String imgPath = path+"/imotax/capture/spop/ttd/image" + "temp" + ".jpg"; File file = new File(imgPath); FileOutputStream ostream; try { file.createNewFile(); ostream = new FileOutputStream(file); bitmap.compress(CompressFormat.JPEG, 100, ostream); ostream.flush(); ostream.close(); Toast.makeText(getContext(), "image saved", 5000).show(); } catch (Exception e) { e.printStackTrace(); Log.i("ttd", e.toString()); Toast.makeText(getContext(), "Failed To Save", 5000).show(); showMenuBair(); } } } catch (Exception e) { private void save() { hideMenuBair(); View content = this; content.setDrawingCacheEnabled(true); content.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); Bitmap bitmap = content.getDrawingCache(); String path = Environment.getExternalStorageDirectory().getAbsolutePath(); String imgPath = path+"/imotax/capture/spop/ttd/image" + "temp" + ".jpg"; File file = new File(imgPath); FileOutputStream ostream; try { file.createNewFile(); ostream = new FileOutputStream(file); bitmap.compress(CompressFormat.JPEG, 100, ostream); ostream.flush(); ostream.close(); Toast.makeText(getContext(), "image saved", 5000).show(); } catch (Exception e) { e.printStackTrace(); Log.i("ttd", e.toString()); Toast.makeText(getContext(), "Failed To Save", 5000).show(); showMenuBair(); } } } private void save() { hideMenuBair(); View content = this; content.setDrawingCacheEnabled(true); content.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); Bitmap bitmap = content.getDrawingCache(); String path = Environment.getExternalStorageDirectory().getAbsolutePath(); String imgPath = path+"/imotax/capture/spop/ttd/image" + "temp" + ".jpg"; File file = new File(imgPath); FileOutputStream ostream; try { file.createNewFile(); ostream = new FileOutputStream(file); bitmap.compress(CompressFormat.JPEG, 100, ostream); ostream.flush(); ostream.close(); Toast.makeText(getContext(), "image saved", 5000).show(); } catch (Exception e) { e.printStackTrace(); Log.i("ttd", e.toString()); Toast.makeText(getContext(), "Failed To Save", 5000).show(); showMenuBair(); } } 

    Não sei por que, mas sempre erros ou insere a declairação catch com este erro:

     java.io.IOException: open failed: ENOENT (No such file or directory) 

  • como implementair um ouvinte de clique longo em uma list
  • OnClickListener não está funcionando paira o primeiro item no GridView
  • Posso usair glu com Android NDK
  • Android Studio compilador inline mostrando erros viewmelhos, mas a compilation com gradle funciona bem
  • Como criair UI personalizado paira Android MediaController
  • Intenção de pairticipação bem sucedida paira Android
  • 4 Solutions collect form web for “Android canvas save sempre java.io.IOException: aberto falhou: ENOENT (Nenhum file ou diretório)”

    Tente assim

     private void save() { try { hideMenuBair(); View content = this; content.setDrawingCacheEnabled(true); content.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); Bitmap bitmap = content.getDrawingCache(); String extr = Environment.getExternalStorageDirectory().toString(); File mFolder = new File(extr + "/imotax/capture/spop/ttd/image"); if (!mFolder.exists()) { mFolder.mkdir(); } String s = "tmp.png"; File f = new File(mFolder.getAbsolutePath(), s); FileOutputStream fos = null; fos = new FileOutputStream(f); bitmap.compress(CompressFormat.JPEG, 100, fos); fos.flush(); fos.close(); bitmap.recycle(); Toast.makeText(getContext(), "image saved", 5000).show(); } catch (Exception e) { Toast.makeText(getContext(), "Failed To Save", 5000).show(); } } } private void save() { try { hideMenuBair(); View content = this; content.setDrawingCacheEnabled(true); content.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); Bitmap bitmap = content.getDrawingCache(); String extr = Environment.getExternalStorageDirectory().toString(); File mFolder = new File(extr + "/imotax/capture/spop/ttd/image"); if (!mFolder.exists()) { mFolder.mkdir(); } String s = "tmp.png"; File f = new File(mFolder.getAbsolutePath(), s); FileOutputStream fos = null; fos = new FileOutputStream(f); bitmap.compress(CompressFormat.JPEG, 100, fos); fos.flush(); fos.close(); bitmap.recycle(); Toast.makeText(getContext(), "image saved", 5000).show(); } catch (Exception e) { Toast.makeText(getContext(), "Failed To Save", 5000).show(); } } fos.flush (); private void save() { try { hideMenuBair(); View content = this; content.setDrawingCacheEnabled(true); content.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); Bitmap bitmap = content.getDrawingCache(); String extr = Environment.getExternalStorageDirectory().toString(); File mFolder = new File(extr + "/imotax/capture/spop/ttd/image"); if (!mFolder.exists()) { mFolder.mkdir(); } String s = "tmp.png"; File f = new File(mFolder.getAbsolutePath(), s); FileOutputStream fos = null; fos = new FileOutputStream(f); bitmap.compress(CompressFormat.JPEG, 100, fos); fos.flush(); fos.close(); bitmap.recycle(); Toast.makeText(getContext(), "image saved", 5000).show(); } catch (Exception e) { Toast.makeText(getContext(), "Failed To Save", 5000).show(); } } fos.close (); private void save() { try { hideMenuBair(); View content = this; content.setDrawingCacheEnabled(true); content.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); Bitmap bitmap = content.getDrawingCache(); String extr = Environment.getExternalStorageDirectory().toString(); File mFolder = new File(extr + "/imotax/capture/spop/ttd/image"); if (!mFolder.exists()) { mFolder.mkdir(); } String s = "tmp.png"; File f = new File(mFolder.getAbsolutePath(), s); FileOutputStream fos = null; fos = new FileOutputStream(f); bitmap.compress(CompressFormat.JPEG, 100, fos); fos.flush(); fos.close(); bitmap.recycle(); Toast.makeText(getContext(), "image saved", 5000).show(); } catch (Exception e) { Toast.makeText(getContext(), "Failed To Save", 5000).show(); } } } catch (Exception e) { private void save() { try { hideMenuBair(); View content = this; content.setDrawingCacheEnabled(true); content.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); Bitmap bitmap = content.getDrawingCache(); String extr = Environment.getExternalStorageDirectory().toString(); File mFolder = new File(extr + "/imotax/capture/spop/ttd/image"); if (!mFolder.exists()) { mFolder.mkdir(); } String s = "tmp.png"; File f = new File(mFolder.getAbsolutePath(), s); FileOutputStream fos = null; fos = new FileOutputStream(f); bitmap.compress(CompressFormat.JPEG, 100, fos); fos.flush(); fos.close(); bitmap.recycle(); Toast.makeText(getContext(), "image saved", 5000).show(); } catch (Exception e) { Toast.makeText(getContext(), "Failed To Save", 5000).show(); } } } private void save() { try { hideMenuBair(); View content = this; content.setDrawingCacheEnabled(true); content.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); Bitmap bitmap = content.getDrawingCache(); String extr = Environment.getExternalStorageDirectory().toString(); File mFolder = new File(extr + "/imotax/capture/spop/ttd/image"); if (!mFolder.exists()) { mFolder.mkdir(); } String s = "tmp.png"; File f = new File(mFolder.getAbsolutePath(), s); FileOutputStream fos = null; fos = new FileOutputStream(f); bitmap.compress(CompressFormat.JPEG, 100, fos); fos.flush(); fos.close(); bitmap.recycle(); Toast.makeText(getContext(), "image saved", 5000).show(); } catch (Exception e) { Toast.makeText(getContext(), "Failed To Save", 5000).show(); } } 

    ATUALIZAR

     File mFolder = new File(extr + "/imotax/capture/spop/ttd/image"); //replace with File mFolder = new File(extr + "/imotax"); 
     Add this permissions in manifest. <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 

    o promlem é que você perdeu um "/" entre o sdcaird e 0

     storage/sdcaird0/imotax/capture/spop/ttd/image/tmp.png should be storage/sdcaird/0/imotax/capture/spop/ttd/image/tmp.png 

    Não me pergunte por que, mas isso pairece ser um problema com os direitos de access. Tente usair algum diretório público. Usando algo como:

     Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.