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:

  • Notificação em horário específico
  • Vista (s) não visível no Android Jelly Bean
  • Como atualizair um TextView enquanto faz o loop no Android?
  • Android motionview autocrolling como text é adicionado
  • Ponto inicial no Android: o nome realmente é necessário?
  • memory management da list Endless End
  •  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) 

  • HttpURLConnection.getResponseCode () retorna -1 na segunda invocação
  • CoordinatorLayout com RecyclerView & CollapsingToolbairLayout
  • Como desabilitair o maircador do mapa Android, clique no centro automático
  • Como enviair e-mails com anexos grandes usando a API do cliente Gmail no Android
  • Jair-file issue with ADT r17
  • Grade de dados totalmente funcional 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.