title: How can I insert image in a sqlite database
body: <p>I want to put an image from camera to database using this database code. What should be the code for the save button and the preview button?</p>
  
  <pre><code>public class databases extends SQLiteOpenHelper {
          public static final String data = "student.db";
          public static final String TABLE_NAME = "Student_TABLE";
          public static final String COL_1 = "Fname";
          public static final String COL_2 = "password";
          public static final String COL_3 = "Fathers_name";
          public static final String COL_4 = "Roll";
          public static final String COL_5 = "Image";
          public databases(Context context) {
              super(context, data, null, 1);
          }
  
          @Override
          public void onCreate(SQLiteDatabase db) {
              db.execSQL("create table " + TABLE_NAME + " (Fname TEXT,password TEXT,Fathers_name TEXT,Roll TEXT PRIMARY KEY,Image BLOB)");
          }
  </code></pre>
  
  <p>Now This is the activity code containing the respective buttons.</p>
  
  <pre><code>public class home_page extends AppCompatActivity {
  Button lout,homepage,showperson,picture;static final int REQUEST_IMAGE_CAPTURE = 1;
  TextView showit;
  String userid,pwrd,r2,r3,r4;
  databases dbss;
      public void getterclass(String m)
      {
          userid=m;
      }
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_home_page);
          lout = (Button) findViewById(R.id.out);
          homepage = (Button) findViewById(R.id.home);
          showit=(TextView) findViewById(R.id.showtextdata);
          showperson=(Button)findViewById(R.id.showdata);
          picture=(Button)findViewById(R.id.images);
          dbss=new databases(home_page.this);
          getSupportActionBar().hide();
          homepage.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Intent redirect=new Intent(home_page.this,home_page.class);
                  startActivity(redirect);
              }
          });
  
          lout.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Intent logout=new Intent(home_page.this,log_in.class);
                          startActivity(logout);
              }
          });
          showperson.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Cursor sh=dbss.givedata(userid);
                  StringBuffer buf=new StringBuffer();
                  buf.append("First name :" + sh.getString(0) + "\n");
                  buf.append("password :" + sh.getString(1) + "\n");
                  buf.append("Father's name :" + sh.getString(2) + "\n");
                  buf.append("Roll :" + sh.getString(3) + "\n\n");
                  showit.setText(buf.toString());
              }
          });
          picture.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                  if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
                      startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
                  }
                  databases help=new databases(home_page.this);
              }
          });
  </code></pre>
  
  <p>The getterclass() is nothing but to retrieve the personal information of the user into other activity however that isn't working as well when I try to display the data to in the same activity.</p>