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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:39:03+00:00 2026-05-23T04:39:03+00:00

Here I am attaching code in which store image in Drawable and pass to

  • 0

Here I am attaching code in which store image in Drawable and pass to Database with BLOB Datatype.

I try this, it store properly but not display image.

Insall_app_db i1 = new Insall_app_db();
i1.createDatabse(DB, getBaseContext());
i1.createTable(tableName, getBaseContext());

BitmapDrawable bitDw = ((BitmapDrawable) icon);
Bitmap bitmap = bitDw.getBitmap();
ByteArrayOutputStream stream = new ByteArrayOutputStream();

bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byte[] imageInByte = stream.toByteArray();
String iconStr = imageInByte.toString();
i1.insertDataUser(tableName,appid,appname2,pname, versionName, versionCode,iconStr, long_date);
int appid = i1.GetUserData(getBaseContext(), tableName);

System.out.println("-------------------------------");
byte[] imaaa = iconStr.getBytes();

Bitmap aaa = convertByteArrayToBitmap(imaaa);

LayoutInflater li = getLayoutInflater();
v = li.inflate(R.layout.icon,null);
TextView tv = (TextView)v.findViewById(R.id.icon_text);
tv.setText(i1.app_name);
ImageView iv = (ImageView)v.findViewById(R.id.icon_image);
iv.setImageResource(R.drawable.icon);
Bitmap bitmap2 = ((BitmapDrawable)icon).getBitmap();
iv.setImageBitmap(aaa);

Is there any other solution to do this thing?

  • 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-23T04:39:04+00:00Added an answer on May 23, 2026 at 4:39 am

    To get the image from the sqlite database i used the following:

     ByteArrayOutputStream baos = new ByteArrayOutputStream();
     byte[] data=cur.getBlob(cur.getColumnIndex("img"));
     baos.write(data);
    

    Then to display the image i used to do the following:

     InputStream is = database.getImageStream(someId);
     Bitmap img = BitmapFactory.decodeStream(is);
    

    The code below shows how to save the image into a BLOB field

    ByteArrayOutputStream bos = new ByteArrayOutputStream();      
    image.compress(CompressFormat.PNG, 100, bos); 
    byte[] bytes = bos.toByteArray(); 
    

    the bytes can be added to sqlite using

     initialValues.put("<fieldname>", bytes); //ofcourse <fieldname> is of type BLOB
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my code, which takes two version identifiers in the form 1, 5,
Here is a simplification of my database: Table: Property Fields: ID, Address Table: Quote
Here's a coding problem for those that like this kind of thing. Let's see
Currently, what I'm doing is this: Using the built-in .NET PrintPreviewDialog Attaching my own
I have tried searching the database for a similar issue, but was unsuccessful in
I have a piece of code related to MapKit which works fine on my
I guess that this is a really stupid question, knowing that .net-code can be
I am attaching to an IE instance which is running my deployed SL 4
I am currently having trouble with the following (here is some sample code first):
I have a problem with this very simple block of code. please give me

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.