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 6884539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:31:18+00:00 2026-05-27T05:31:18+00:00

I defined a method to add an entry in my database helper class and

  • 0

I defined a method to add an entry in my database helper class and insert data into database using it, but it is not working. This is my method defined in databasehelper class:

 public void createchannelEntry(ChannelPoster channel) {
        openDB();
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        channel.getPoster().compress(Bitmap.CompressFormat.PNG, 100, out);
        ContentValues cv = new ContentValues();
        cv.put(KEY_POSTER, out.toByteArray());            
        cv.put(KEY_CHANNEL, channel.getChannel());
        cv.put(KEY_PATH, channel.getPath());
        cv.put(KEY_DBLINK, channel.getDBlink());

        mDb.insert(channelS_TABLE, null, cv);
        closeDB();
    }

this is how I insert data

Bitmap sherlock = BitmapFactory.decodeResource(getResources(), R.drawable.sherlock);

mDB.createchannelEntry(new ChannelPoster(sherlock, "aa" ,"ll"  ,"ha" ));

and I have a JavaBean for holding an entry

public class ChannelPoster {
    private Bitmap poster;
    private String channel;
    private String path;
    private String dblink;

    public ChannelPoster(Bitmap pi, String c, String p, String d) {
        poster = pi;
        channel = c;
        path = p;
        dblink = d;
    }

    public Bitmap getPoster() { return poster; }
    public String getChannel() { return channel; }
    public String getPath() { return path; }
    public String getDBlink() { return dblink; }
}

And because I am adding entries one by one, the program runs very slow, so it’s there a faster way to insert many entries? like get all of them in one event?

  • 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-05-27T05:31:19+00:00Added an answer on May 27, 2026 at 5:31 am

    I suggest not saving the images in the database, but rather saving them as files, and saving a path to them in the database (using a normal TEXT field).

    If you don’t want to do that, there are two things that will still greatly improve the speed of your processing:

    • Open and close the database only once around all your inserts
    • Use a transaction

    Something like that:

    SQLiteDatabase db = openDB();
    db.beginTransaction();
    
    try {
        // Add here the loop with all your inserts
        db.setTransactionSuccessful();
    } finally {
        db.endTransaction();  // will rollback and cancel the inserts if not marked as successful
        db.close();
    }
    

    (the finally is there to make sure you close the transaction and the connection even if it somehow fails during the inserts: in this case ALL your inserts will be cancelled)

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

Sidebar

Related Questions

i have a code like this i have defined the method goNext but still
I've got a class defined with a method to add items to it: class
I am trying to use (*env)->RegisterNatives to add methods to a defined class which
I have a class 'Collection', which has an add method. The add method should
Opinions divided on this one ... Guys, say you have a method defined as
I am in a single class, using 2 different methods. In one method I
I'm trying to insert a column into an existing DataSet using C#. As an
I have defined a class called Stone to add graphical stones to a JPanel:
Consider I have defined the following models: class Tag(models.Model): name = models.CharField(max_length=20) class Entry(models.Model):
I've got an object defined like this: data = {name: 'durk durk durk', site_id:

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.