title: Convert selected image into byte array and into string
body: <p>I am working on client-server communication. 
  Users can select an image from gallery. 
  Selected images would be saved in two places, local DB and server DB. 
  If users save it, the selected image would be saved into local database with path(String) 
  and also should be saved into Server database. 
  The problem is I don't know how to get images byte array to encode to String to pass the image to server side. </p>
  
  <p>Local DB : Image -> Path(String) (This is done)
  Server DB : Image -> Byte -> String -> Send to server</p>
  
  <p>Here is the code..</p>
  
  <pre><code>    Bundle extras = getIntent().getExtras();
  
      if (extras != null) {
          id=extras.getInt("id");
          inputname.setText(extras.getString("name"));
          inputnote.setText(extras.getString("note"));
  
          image = extras.getString("blob");
  
  
          //Convert image into string to save path in local DB
          BitmapFactory.Options op=new BitmapFactory.Options();
          op.inSampleSize=8;
          yourSelectedImage = BitmapFactory.decodeFile(image, op);
          inputphoto.setImageBitmap(yourSelectedImage);
  
      }
  </code></pre>
  
  <p>How to set blob in the saveItem method..?</p>
  
  <pre><code>private void saveItem() {
  
      // Client-Server - Start //////////////////////////////////////
      String name = inputname.getText().toString();
      String description = inputnote.getText().toString();
      // Encode the image file to String !! by using Base64
      String encodedImage = Base64.encodeToString(blob, Base64.DEFAULT);
  
      // Building Parameters
      List&lt;NameValuePair&gt; params1 = new ArrayList&lt;NameValuePair&gt;();
      params1.add(new BasicNameValuePair("name", name));
      params1.add(new BasicNameValuePair("description", description));
      params1.add(new BasicNameValuePair("photo",encodedImage));
  
      Log.v("log_tag", System.currentTimeMillis()+".jpg");
  
  
      // getting JSON Object
      // Note that create product url accepts POST method
      JSONObject json = jsonParser.makeHttpRequest(url_create_product, "POST", params1);
  
      // check log cat fro response
      Log.d("Create Response", json.toString());
  
      // check for success tag
      try {
          int success = json.getInt(TAG_SUCCESS);
  
  
          Log.v("log_tag", "In the try Loop" );
  
          if (success == 1) {
              // closing this screen
              finish();
          } else {
              // failed to create product
          }
      } catch (JSONException e) {
          e.printStackTrace();
      }
  </code></pre>
  
  <p>Thank you in advance. </p>