1

I am trying to save images in SQLite.I have created an app that takes a picture and compares it with saved images in SQLite.So how can I store images in SQLite?

I used BLOB data type for storing images

NewAccount.java

public void insertUserData()
    {


        /**
         * STUDENT DATABASER
         */

        ContentValues contentValues1 =  new ContentValues();
        contentValues1.put(LoginEntryStudent.STUDENT_COLUMN_ROLL_NO,"17121070");
        contentValues1.put(LoginEntryStudent.STUDENT_COLUMN_FIRST_NAME,"Gautam");
        contentValues1.put(LoginEntryStudent.STUDENT_COLUMN_LAST_NAME,"Helange");
        contentValues1.put(LoginEntryStudent.STUDENT_COLUMN_PHONE_NUMBER,"7517424135");
        contentValues1.put(LoginEntryStudent.STUDENT_COLUMN_EMAIL_ID,"gautamhelange025@gmail.com");
        contentValues1.put(LoginEntryStudent.STUDENT_COLUMN_GENDER,LoginEntryStudent.STUDENT_GENDER_MALE);


        //what value put there so image will be save from my mobile gallery
        contentValues1.put(LoginEntryStudent.STUDENT_COLUMN_IMAGE,"what put here");

        Uri newUriStudent = getContentResolver().insert(LoginEntryStudent.CONTENT_URI_STUDENT,contentValues1);

        Intent i = new Intent(NewAccount.this,WelcomeApp.class);
        startActivity(i);
    }
Swayangjit
  • 1,557
  • 2
  • 10
  • 17

1 Answers1

1

Convert your image into Base64 format then save into sqlite.

check the first answer of this link to know how to convert image into base64

Kamesh Talreja
  • 112
  • 1
  • 9