title: Aceessing Image from Sqlite Database
body: <p>I have a problem in my code that I am storing accessing the student data from sqlite database with student name, age and picture. I am storing all these data perfectly but cannot access the image field only.</p>
  
  <p>Image shows blank on the screen,</p>
  
  <p>I don't know why. Please Review my code and give me useful suggestions.</p>
  
  <p>Thank You..</p>
  
  <p>Here is Code:</p>
  
  <pre><code>package com.ex.imageStore;
  
  import java.util.Locale;
  
  import android.app.Activity;
  import android.database.Cursor;
  import android.database.sqlite.SQLiteDatabase;
  import android.graphics.BitmapFactory;
  import android.os.Bundle;
  import android.widget.ImageView;
  import android.widget.TextView;
  
  public class NewScreen extends Activity{
        SQLiteDatabase db;
  
      @Override
      public void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.newscreen);
          TextView name = (TextView)findViewById(R.id.textView1);
          TextView age = (TextView)findViewById(R.id.textView2);
          ImageView img = (ImageView)findViewById(R.id.imageView1);
  
          db = openOrCreateDatabase(
                  "StudentData.db"
                  , SQLiteDatabase.CREATE_IF_NECESSARY
                  , null
                  );
  
           db.setVersion(1);
              db.setLocale(Locale.getDefault());
              db.setLockingEnabled(true);
  
              Cursor cur = db.query("stuData", 
                      null, null, null, null, null, null);
                  //cur.moveToFirst();
              cur.moveToPosition(0);
              name.setText(cur.getString(1));
              age.setText(cur.getString(2));
              byte[] bb = cur.getBlob(3);
   Bitmap theImage = BitmapFactory.decodeByteArray(bb,0,bb.length);
              img.setImageBitmap(theImage);//-->It //cannot convert bytearray to bitmap
                 /* while (cur.isAfterLast() == false) {
                      tv.append("n" + cur.getString(1));
                      cur.moveToNext();
                  }*/
                  cur.close();
  
  
      }
  
  }</code></pre>
  
  <p>theImage variable always assigned as null.........</p>