title: Data is not inserting to database when image is null
body: <p>I want to store data into the database and want to upload an image in optional.</p>
  
  <p>It means that if i am inserting the record without adding image then it will store in database without the image name.</p>
  
  <p>right now when i am fill the data and insert an image then it is storing in the database if i don't select any image and i add only data then in database the data is not inserted and showing me blank value in every field</p>
  
  <p>I tried a lot but not getting the required output.</p>
  
  <p>My code <strong>main.java</strong></p>
  
  <pre><code>    buy_image1.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  selectImage();
                  edit.putInt("ImageID", 1);
                  edit.commit();
  
  
              }
          });
  
          public void selectImage()
      {
          i = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
          startActivityForResult(i, RESULT_LOAD_IMAGE);
          /*i.putExtra("crop", "true");
          i.putExtra("outputX", 512);
          i.putExtra("outputY", 512);
          i.putExtra("aspectX", 1);
          i.putExtra("aspectY", 1);
          i.putExtra("scale", true);
      */
      }
      public void onActivityResult(int requestCode, int resultCode, Intent data)
      {
          super.onActivityResult(requestCode, resultCode, data);
          if (requestCode == RESULT_LOAD_IMAGE &amp;&amp; resultCode == getActivity().RESULT_OK &amp;&amp; null != data) {
              final int IMAGE_MAX_SIZE = 1200000; // 1.2MP
  
              Uri selectedImage = data.getData();
              int imgid = 0;
              String[] filePathColumn = {MediaStore.MediaColumns.DATA};
  
             Cursor cursor = getActivity().getContentResolver().query(selectedImage, filePathColumn, null, null, null);
              cursor.moveToFirst();
  
              int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
              picturePath = cursor.getString(columnIndex);
              cursor.close();
              Log.d("Value", picturePath);
              fileName = new File(picturePath).getName();
              // imgname.setText(fileName);
  
              String fileNameSegments[] = picturePath.split("/");
              fileName = fileNameSegments[fileNameSegments.length - 1];
  
              // MyParams.put("filename", fileName);
              Bitmap yourSelectedImage = BitmapFactory.decodeFile(picturePath);
  
              sp = getActivity().getSharedPreferences("Image ID", Context.MODE_PRIVATE);
              imgid = sp.getInt("ImageID", 0);
              Log.d("IMGID", Integer.toString(imgid));
  
  
              BitmapFactory.Options options =null;
              options = new BitmapFactory.Options();
              options.inSampleSize = 5;
              bitmap = BitmapFactory.decodeFile(picturePath, options);
              ByteArrayOutputStream stream = new ByteArrayOutputStream();
              bitmap.compress(Bitmap.CompressFormat.JPEG, 85, stream);
  
              byte[] byte_arr = stream.toByteArray();
              // Encode Image to String
              encodedString = Base64.encodeToString(byte_arr, 0);
  
  
              if(imgid == 1) {
                  buy_image1.setImageBitmap(yourSelectedImage);
                  img1 = fileName;
                  encodedStringIMG1 = encodedString;
              }else if(imgid == 2){
  
                  buy_image2.setImageBitmap(yourSelectedImage);
                  img2 = fileName;
                  encodedStringIMG2 = encodedString;
  
              }
          else{
                  Log.d("IMGID","IMAGE ID IS 0");
              }
      }
      private void InsertWodinformation() {
  
          service(strwodname,strbranch,strcontactperson,strcontact,strwhatsapp,stremail,
                  strspinnercity,straddress,opendate1,birthdate,ani,strpancard,strtinnumber,strbankname,strbankholdername,strbankac,
                  strbankcity, strifsccode,strsecuritycheque,strrefrence1,strrefrence2,strremarks,img1,encodedStringIMG1,img2,encodedStringIMG2);
      }
  private void service(
          String strwodname,String strbranch,
          String strcontactperson, String strcontact,
          String strwhatsapp, String stremail, String strspinnercity,
          String straddress, String opendate1, String birthdate, String ani,
          String strpancard, String strtinnumber, String strbankname, String strbankholdername
          ,String strbankac,String strbankcity, String strifsccode,String strsecuritycheque,String strrefrence1,
          String strrefrence2,String strremarks,String i1,String encode1,String i2,String encode2
    ) {
  
          class AddVisitclass extends AsyncTask&lt;String, Void, String&gt; {
              ProgressDialog loading;
              RegisterUserClass ruc = new RegisterUserClass();
  
              @Override
              protected void onPreExecute() {
                  super.onPreExecute();
              }
              @Override
              protected String doInBackground(String... params) {
  
  
                  HashMap&lt;String, String&gt; param = new HashMap&lt;String, String&gt;();
  
  
                  /*param.put("firm", params[1]);
                  param.put("oname", params[2]);
                  param.put("pname1", params[3]);
                  param.put("pname2", params[4]);
                  */
                  param.put("wname", params[0]);
                  param.put("branch", params[1]);
                  param.put("cname", params[2]);
                  param.put("contact", params[3]);
                  param.put("whatsapp", params[4]);
                  param.put("email", params[5]);
  
                  param.put("city", params[6]);
                  param.put("address", params[7]);
                  param.put("odate", params[8]);
                  param.put("bdate", params[9]);
                  param.put("adate", params[10]);
                  param.put("pancard", params[11]);
                  param.put("tinno", params[12]);
                  param.put("bnm", params[13]);
                  param.put("bank_ac_holder", params[14]);
                  param.put("bank_ac_no", params[15]);
                  param.put("bcity", params[16]);
                  param.put("ifsc_code", params[17]);
                  param.put("cheque", params[18]);
                  param.put("ref1", params[19]);
                  param.put("ref2", params[20]);
                  param.put("remarks", params[21]);
  
                  param.put("pan", params[22]);
                  param.put("epan", params[23]);
                  param.put("aadhar", params[24]);
                  param.put("eaadhar", params[25]);
  /*
  
  
                  param.put("light", params[26]);
                  param.put("elight", params[27]);
  
                  param.put("vat", params[28]);
                  param.put("evat", params[29]);
  
                  param.put("vcard", params[30]);
                  param.put("evcard", params[31]);
  
                  param.put("shop", params[32]);
                  param.put("eshop", params[33]);
  */
  
  
  
                  param.put("username",uid);
                  String result = ruc.sendPostRequest(url_addwod, param);
                  Log.d("Result", result);
                  Log.d("Data", param.toString());
                  return result;
              }
              //@Override
              protected void onPostExecute(String result) {
                  super.onPostExecute(result);
                  //loading.dismiss();
  
  
                  Toast.makeText(getActivity(), "W.O.D. added successfully...!!!", Toast.LENGTH_LONG).show();
                  /* FragmentTransaction t = getActivity().getSupportFragmentManager().beginTransaction();
                  TabFragment mFrag = new TabFragment();
                  t.replace(com.Weal.sachin.omcom.R.id.framelayout, mFrag);
                  t.commit();
                  */
              }
          }
          AddVisitclass regi = new AddVisitclass();
          regi.execute(strwodname,strbranch,strcontactperson,strcontact,strwhatsapp,stremail,
                  strspinnercity,straddress,opendate1,birthdate,ani,strpancard,strtinnumber,strbankname,strbankholdername,strbankac,
                  strbankcity, strifsccode,strsecuritycheque,strrefrence1,strrefrence2,strremarks,i1,encode1,i2,encode2);
      }
  </code></pre>
  
  <p>And one more thing when image is uploading to the server it is generating the lower size but i want it in default size.</p>