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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:17:40+00:00 2026-06-17T14:17:40+00:00

I am trying to Store an Bitmap as BLOB and some Strings in the

  • 0

I am trying to Store an Bitmap as BLOB and some Strings in the same SQLdatase.

Here is my DataBase:

// Updating single contact

public int update(String name, String email, String uid, String tel, String niver, String created_at, byte[] thumb) {
    SQLiteDatabase db = this.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put(KEY_NAME, name); // Name
    values.put(KEY_EMAIL, email); // Email
    values.put(KEY_UID, uid); // Email
    values.put(KEY_TEL, tel); // Telefone
    values.put(KEY_NIVER, niver); // Niver
    values.put(KEY_CREATED_AT, created_at); // Created At
    values.put(KEY_THUMB, thumb); // thumb

    //db.close(); // I deleted this line

    // updating row
    return db.update(TABLE_LOGIN, values, KEY_THUMB + " = ?",
            new String[] { String.valueOf(getRowCount()) });
}

I use this to update database with a Bitmap;

                    imagebutton.setImageBitmap(photo);
                    imagebutton.setScaleType(ScaleType.FIT_XY);
                    ByteArrayOutputStream stream = new ByteArrayOutputStream();
                    photo.compress(Bitmap.CompressFormat.JPEG, 100, stream);
                    byte[] imageInByte = stream.toByteArray();
                    db.update(null, null, null, null, null, null, imageInByte);

Logs:

01-21 15:47:47.445: E/AndroidRuntime(24673): FATAL EXCEPTION: main
01-21 15:47:47.445: E/AndroidRuntime(24673): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=65538, result=-1, data=Intent { act=inline-data (has extras) }} to activity {br.com.example.nightid/br.com.example.nightid.main.BaseSampleActivity}: java.lang.IllegalStateException: database not open
01-21 15:47:47.445: E/AndroidRuntime(24673):    at android.app.ActivityThread.deliverResults(ActivityThread.java:2536)
01-21 15:47:47.445: E/AndroidRuntime(24673):    at android.app.ActivityThread.handleSendResult(ActivityThread.java:2578)
01-21 15:47:47.445: E/AndroidRuntime(24673):    at android.app.ActivityThread.access$2000(ActivityThread.java:117)
01-21 15:47:47.445: E/AndroidRuntime(24673):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:965)
01-21 15:47:47.445: E/AndroidRuntime(24673):    at android.os.Handler.dispatchMessage(Handler.java:99)
01-21 15:47:47.445: E/AndroidRuntime(24673):    at android.os.Looper.loop(Looper.java:130)
01-21 15:47:47.445: E/AndroidRuntime(24673):    at android.app.ActivityThread.main(ActivityThread.java:3687)
01-21 15:47:47.445: E/AndroidRuntime(24673):    at java.lang.reflect.Method.invokeNative(Native Method)
01-21 15:47:47.445: E/AndroidRuntime(24673):    at java.lang.reflect.Method.invoke(Method.java:507)
01-21 15:47:47.445: E/AndroidRuntime(24673):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
01-21 15:47:47.445: E/AndroidRuntime(24673):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
01-21 15:47:47.445: E/AndroidRuntime(24673):    at dalvik.system.NativeStart.main(Native Method)
01-21 15:47:47.445: E/AndroidRuntime(24673): Caused by: java.lang.IllegalStateException: database not open
01-21 15:47:47.445: E/AndroidRuntime(24673):    at android.database.sqlite.SQLiteDatabase.updateWithOnConflict(SQLiteDatabase.java:1712)
01-21 15:47:47.445: E/AndroidRuntime(24673):    at android.database.sqlite.SQLiteDatabase.update(SQLiteDatabase.java:1666)
01-21 15:47:47.445: E/AndroidRuntime(24673):    at com.example.androidhive.library.DatabaseHandler.update(DatabaseHandler.java:150)
01-21 15:47:47.445: E/AndroidRuntime(24673):    at br.com.example.nightid.slidingmenu.SlidingFragment.onActivityResult(SlidingFragment.java:204)
01-21 15:47:47.445: E/AndroidRuntime(24673):    at android.support.v4.app.FragmentActivity.onActivityResult(FragmentActivity.java:161)
01-21 15:47:47.445: E/AndroidRuntime(24673):    at android.app.Activity.dispatchActivityResult(Activity.java:3919)
01-21 15:47:47.445: E/AndroidRuntime(24673):    at android.app.ActivityThread.deliverResults(ActivityThread.java:2532)
01-21 15:47:47.445: E/AndroidRuntime(24673):    ... 11 more
  • 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-17T14:17:42+00:00Added an answer on June 17, 2026 at 2:17 pm

    With this code, it works now:

     public int updateUser(byte[] thumb) {
            SQLiteDatabase db = this.getWritableDatabase();
            ContentValues values = new ContentValues();
            values.put(KEY_THUMB, thumb); // thumb
            Log.w(TAG, String.valueOf(thumb));
            // updating row
            return db.update(TABLE_LOGIN, values, null,
                    null );
        }
    

    new String[] { String.valueOf(getRowCount()) } was giving me this error on logcat.

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

Sidebar

Related Questions

I'm trying to store an image into an SQL database without using temporary files.
I'm trying to store several 2D sprites inside a single texture, since I figured
I'm trying to store the size of a queue in an int in C++.
I have been trying to store image form android sdcard to the sqlite database.
I am trying to serialize a Bitmap to store in an XML file. My
I am trying to store a bitmap (that i have previously read from a
I am trying to store some objects in an SQL Server Compact (SQL CE)
I'm trying to store a hierarchical tree in SQL. In my case, the same
Im trying to store a list,collection of data objects in Hbase. For example ,a
I am trying to store a byteArrayInputStream as File on a FTP Server .

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.