title: Insert images into sql server and retrieve it
body: <p>I want to add some images into my SQL server. Is my problem from the insertion  or getting image code?</p>
  
  <p>For now the imageview that I retrieve the image is blank.</p>
  
  <p>Here is my code for inserting the image:</p>
  
  <pre class="lang-java prettyprint-override"><code>else {
      DatabaseHelper mDatabaseHelper = new DatabaseHelper(MainActivity.this);
      Cursor cursor2 = mDatabaseHelper.GetPath();
      while (cursor2.moveToNext()) {
  
          Bitmap bitmap = BitmapFactory.decodeFile(cursor2.getString(0));
          ByteArrayOutputStream blob = new ByteArrayOutputStream();
          bitmap.compress(Bitmap.CompressFormat.JPEG, 100 /* Ignored for PNGs */ , blob);
          byte[] bitmapdata = blob.toByteArray();
          String id = getIntent().getStringExtra("id");
          String query = "INSERT INTO StoresData VALUES('" + arabic + "','" + english + "','1','1','1','1','1','','" + lat + "','" + longi + "','" + mob + "','','','','','','','','0','','','','" + bitmapdata + "','" + user + "','" + passwords + "','0',NULL,'" + id + "')";
          Statement stmt = con.createStatement();
          stmt.executeUpdate(query);
  
          Cursor cursor = mDatabaseHelper.DeleteDataOfTableImagesAr();
          while (cursor.moveToNext()) {
              Toast.makeText(MainActivity.this, "Deleted images", Toast.LENGTH_LONG).show();
          }
      }
  }
  </code></pre>
  
  <p>Retrieve the image back:</p>
  
  <pre class="lang-java prettyprint-override"><code>Blob blob = parkingList.get(position).getStoreicon();
  if (blob != null) {
      byte[] byteArray = new byte[0];
      try {
          int length = (int) blob.length();
          byteArray = blob.getBytes(1, length);
      } catch (SQLException e) {
          e.printStackTrace();
      }
      Bitmap bm = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
      intent.putExtra("storeicon", bm);
  } else {
  
  }
  </code></pre>
  
  <p>And yes I am getting the image into a listview.</p>
  
  <p>Retrieving and getting the image are done in two different applications that is why I didn't use SQLite.</p>