Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8301857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:08:49+00:00 2026-06-08T17:08:49+00:00

I have a problem regarding inserting objects to a SQLite database. My class, Case

  • 0

I have a problem regarding inserting objects to a SQLite database. My class, Case looks like this:

public class Case {

String caseNumber; 
int status; 
String date;
Bitmap rightIndexFinger;
Bitmap leftIndexFinger; 


public Case(String caseNumber, int status, String date, Bitmap rightIndexFinger, Bitmap leftIndexFinger) {

    this.caseNumber = caseNumber;
    this.status = status;
    this.date = date;
    this.rightIndexFinger = rightIndexFinger;
    this.leftIndexFinger = leftIndexFinger; 

}

public Case(String caseNumber, int status, String date) {

    this.caseNumber = caseNumber;
    this.status = status;
    this.date = date;
}


public Bitmap getRightIndexFinger() {
    return rightIndexFinger;
}


public void setRightIndexFinger(Bitmap rightIndexFinger) {
    this.rightIndexFinger = rightIndexFinger;
}


public Bitmap getLeftIndexFinger() {
    return leftIndexFinger;
}


public void setLeftIndexFinger(Bitmap leftIndexFinger) {
    this.leftIndexFinger = leftIndexFinger;
}


public String getCaseNumber() {
    return caseNumber;
}


public void setCaseNumber(String caseNumber) {
    this.caseNumber = caseNumber;
}


public int getStatus() {
    return status;
}


public void setStatus(int status) {
    this.status = status;
}


public String getDate() {
    return date.toString();
}


public void setDate(String date) {
    this.date = date;
}
}

I need to insert objects of this class into a SQLite database. What I tried is:

String CREATE_CONTACTS_TABLE = "CREATE TABLE " + TABLE_CASES + "("
                + KEY_ID + " INTEGER PRIMARY KEY," + DATE + " TEXT,"
                + RIGHTFINGER + " TEXT," + LEFTFINGER +" TEXT" + ")";
        db.execSQL(CREATE_CONTACTS_TABLE);

This make sense if all of my variables in the case class was String, but how can I do this for Bitmaps?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T17:08:51+00:00Added an answer on June 8, 2026 at 5:08 pm

    Convert Bitmap to Byte Array, and then save this byte array into database in Blob datatype. By folloqing code:

    To convert a bitmap to byte array use following code:

    Bitmap image = BitmapFactory.decodeResource(getResources(), R.drawable.thumbnail);
    
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    
    image.compress(Bitmap.CompressFormat.PNG, 100, out);
    
    byte[] buffer=out.toByteArray();
    

    To save a byte array in blob type use following code:

    ContentValues cv=new ContentValues();
       cv.put(CHUNK, buffer);       //CHUNK blob type field of your table
       long rawId=database.insert(TABLE, null, cv); //TABLE table name
    

    Read more about Blob by this link

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a cross-language problem regarding md5 :). I have this code in Java:
I have a problem regarding multithreading and inserting an item to an Dictionary. The
I have one problem regarding retriving data from database. I have created one database
I have a problem regarding android database.I have an app which have it's database
I have a problem regarding StartUp Url in WPF. I have a LoginView.xaml and
I have a problem regarding the datediff MYSQL function, I can use it and
I have a problem regarding the ksoap2. My problem is that the project used
I have a problem regarding Android App. I have created an application that download
Description: I have a problem regarding DataGridView . I need to show a Client_Name
I have the following code, and i have a problem regarding changing the ringtone

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.