title: Android save and share Image From SDCard
body: <p>Hi I'm Trying to save a drawable as a bitmap to the SDCard and then share it using a share intent. but the problem i'm having is that its just not sharing the image does anyone know how to do this or where im going wrong?</p>
  
  <p>heres what i have tried so far</p>
  
  <pre><code>getHelp.setOnClickListener(new View.OnClickListener() {
  
                          public void onClick(View arg0) {
  
                              saveBitmapToExternalStorage(this, imageResourceFor Drawable, imageName);
                              File imageFile = new File("/sdcard/myfolder/"+ kitImagePath+".png");
                              Bitmap bitmap = BitmapFactory.decodeFile(imageFile.getAbsolutePath());
                              Intent shareIntent = new Intent();
                              shareIntent.setAction(Intent.ACTION_SEND);
                              shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Title");
                              shareIntent.putExtra(Intent.EXTRA_TEXT, "Subtitle");
                              shareIntent.putExtra(Intent.EXTRA_STREAM, bitmap);  //optional//use this when you want to send an image
                              shareIntent.setType("image/png");
                              shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                              startActivity(Intent.createChooser(shareIntent, "send"));
                          }
  
                      });
  
   public static void saveBitmapToExternalStorage(Context context, int imageResource, String imageName){
  
          Bitmap bitmap=BitmapFactory.decodeResource(context.getResources(),imageResource);
  
          //generate file
          File dir = new File (Environment.getExternalStorageDirectory(), "/myfolder");
          File f = new File(dir, String.format(imageName + ".png"));
  
          ByteArrayOutputStream bos = new ByteArrayOutputStream();
          bitmap.compress(CompressFormat.PNG, 0 , bos);
          byte[] bitmapdata = bos.toByteArray();
          FileOutputStream fos;
          try {
              fos = new FileOutputStream(f);
              fos.write(bitmapdata);  
              fos.flush();
              fos.close();
              bos.close();
  
          } catch (FileNotFoundException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
      }
  </code></pre>