title: How to get Base64 String from InputStream?
body: <p>I'm on a problem by taking the selected gallery picture and want to save it first as <code>Base64</code> <code>String</code> in a XML file (for later use. For example if you exit the app and open it again).</p>
  
  <p>As you can see I get the Image on a <code>InputStream</code></p>
  
  <p>But first of all the <code>onClick</code> method:</p>
  
  <pre><code>public void onClick(DialogInterface dialog, int which) {
                      pictureActionIntent = new Intent(Intent.ACTION_GET_CONTENT);
                      pictureActionIntent.setType("image/*");
                      startActivityForResult(pictureActionIntent,GALLERY_PICTURE);
                  }
  </code></pre>
  
  <p>Now in the <code>onActivityResult</code> method I want to store the image from <code>InputStream</code> to <code>Base64</code> <code>String</code>.</p>
  
  <pre><code>case GALLERY_PICTURE:
  
   if (resultCode == RESULT_OK &amp;&amp; null != data) {
       InputStream inputstream = null;
       try {
            inputstream = getApplicationContext().getContentResolver().openInputStream(data.getData());
            Base64InputStream in = new Base64InputStream(inputstream,0);
       } catch (IOException e) {
            e.printStackTrace();
   }
  </code></pre>
  
  <p><strong>@EDIT</strong>
  This is what I do after creating the base64 String.</p>
  
  <pre><code>Bitmap bmp = base64EncodeDecode.decodeBase64(Items.get("image"));
  Image1.setImageBitmap(bmp);
  </code></pre>
  
  <p>And this is the decoding Method:</p>
  
  <pre><code>    public Bitmap decodeBase64(String input) {
      byte[] decodedByte = Base64.decode(input, Base64.DEFAULT);
      return BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length);
  }
  </code></pre>
  
  <p>I tried to use <code>Base64InputStream</code> but without success.
  Can you give me a hint how to get from <code>InputStream</code> to <code>Base64</code> <code>String</code>?</p>
  
  <p>How many steps it will take doesn't matter.</p>
  
  <p>I hope someone can help me!</p>
  
  <p>Kind Regards!</p>