title: retrieving data from mysql database and inserting into sqlite and displaying in the imageview
body: <p>I have a set of images with names.I have created image table with two columns in mysql. I am inserting the images to mysql database using the following code.</p>
  
  <pre><code>if(getimagesize($_FILES['image']['tmp_name']) == FALSE)
              {
                  echo "&lt;script&gt;alert('Please select an image')&lt;/script&gt;";
              }           
          else 
              {
                  $image= addslashes($_FILES['image']['tmp_name']);
                   $name=$productname;
                  $image= file_get_contents($image);
                  $image= base64_encode($image);
                  $qry="insert into images (products,image) values ('$name','$image')";
                  $result=mysql_query($qry,$con);
              }
  </code></pre>
  
  <p>For retreiving and displaying the inserted images i am using the following code.</p>
  
  <pre><code>while($row = mysql_fetch_array($result))
              {
  
                   $productname = $row['products'];
                  echo '&lt;tr align="center" height="70"&gt;';
                  echo '&lt;td&gt;';
                  echo $row[0];
                  echo '&lt;/td&gt;';
                  echo '&lt;td&gt;';
                  echo '&lt;img height="200" width="200" src="data:image;base64,'.$row[1].' "&gt; ';
                  echo '&lt;/td&gt;';
                  print("&lt;td width='100'&gt;&lt;a href='imagedelete.php?id=$row[products]'&gt;Delete&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;");
  
              } 
  </code></pre>
  
  <p>Inserting and displaying the all the images are happening correctly using the mysql database.</p>
  
  <p>I tried this code to insert and retrieve and display using sqlite but didnt work.</p>
  
  <pre><code>SQLiteDatabase database = this.getWritableDatabase();
  String q="SELECT image FROM Product_Image where products='" + productitem + "'";
  Cursor cursor = database.rawQuery(q, null);
  cursor.moveToFirst();
  byteImage2 = cursor.getBlob(2);
  productimage.setImageBitmap(BitmapFactory.decodeByteArray(byteImage2,0, byteImage2.length));
  </code></pre>
  
  <p>My doubts is</p>
  
  <ol>
  <li>I want to retrive the images from the mysql database and insert to sqlite database.How will i do that.                                       </li>
  <li>After inserting i want to retrieve the image from sqlite database and display in the image view.How will i do this.</li>
  </ol>
  
  <p>Please help.Code for my doubts would be helpful.</p>