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

  • Home
  • SEARCH
  • 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 6026411
In Process

The Archive Base Latest Questions

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

public Drawable icon; \\ Some value in this field I am creating a database

  • 0
public Drawable icon; \\ Some value in this field

I am creating a database in SQLite Manager. I want to store icon into the database. Another field is shown correctly, but when I take the icon field with datatype BLOB, it doesn’t display.

public void prettyPrint() {
public String appname = "asd";
public String pname = "asd";
public String versionName = "asd";
public int versionCode = 0;
public Drawable icon="android.im....";
Insall_app_db i1 = new Insall_app_db();
i1.createDatabse("appInfo3", getBaseContext());
i1.createTable("off_appinfo4", getBaseContext()); i1.insertDataUser("off_appinfo4",  appid ,appname,pname, versionName, versionCode, icon, x);
}


package com.AppInfo;

import java.sql.Blob;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

import android.R.drawable;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.drawable.Drawable;

public class Insall_app_db {


SQLiteDatabase sampleDB = null;
String PhoneNumber;
String UserId;
Cursor c;
ArrayList ar=new ArrayList();
public void createDatabse(String DbName,Context context)
{
sampleDB =  context.openOrCreateDatabase(DbName,     
    context.MODE_WORLD_READABLE,null);

}

public void createTable(String Tablename,Context context)
{
    sampleDB.execSQL("CREATE TABLE IF NOT EXISTS " +
            Tablename +
            "(app_id INT,app_name VARCHAR(255),pname VARCHAR(255),version_name  VARCHAR(25),versionCode  INT,icon BLOB,date DATE);");

}
public void DeleteTable(String Tablename,Context context)
{
    sampleDB.execSQL("DROP TABLE off_appinfo4");

}

public void insertDataUser(String tableName,int app_id,String app_name,String pname,String version_name,int versionCode,String d,long date1)
{

     sampleDB.execSQL("INSERT INTO " +
             tableName +
             " Values ("+app_id+",'"+app_name+"','"+pname+"','"+version_name+"','"+versionCode+"','"+d+"',"+date1+");");


}

public String GetUserData(Context context,String tablename)
{
            c = sampleDB.rawQuery("SELECT User_Id FROM " +
                tablename +
                "", null);

            if(c!=null)
            {
                if(c.moveToFirst())
                {
                    do
                    {
                        UserId=c.getString(c.getColumnIndex("User_Id"));

                    }while(c.moveToNext());



                    }   

                }       

            return UserId;
}

public void close()
{
    sampleDB.close();

}




}
  • 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:26:29+00:00Added an answer on May 23, 2026 at 4:26 am

    You can convert your image into byte array and store that bytearray in blob filed in database. You can retrieve your image back from database as byte array.

    How to get byte array from imageview:

    ImageView iv = (ImageView) findViewById(R.id.splashImageView);
    Drawable d = iv.getBackground();
    BitmapDrawable bitDw = ((BitmapDrawable) d);
    Bitmap bitmap = bitDw.getBitmap();
    System.out.println(".....d....."+d);
    System.out.println("...bitDw...."+bitDw);
    System.out.println("....bitmap...."+bitmap);
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
    byte[] imageInByte = stream.toByteArray();
    

    Store byte array in database:

    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
    

    Retrieve image from byte array:

    public static Bitmap convertByteArrayToBitmap(
        byte[] byteArrayToBeCOnvertedIntoBitMap)
    {
        bitMapImage = BitmapFactory.decodeByteArray(
            byteArrayToBeCOnvertedIntoBitMap, 0,
            byteArrayToBeCOnvertedIntoBitMap.length);
        return bitMapImage;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want the messagebox to only show if the number is equal to 0.
I have found this example on StackOverflow: var people = new List<Person> { new
My question is about memory use and objects in actionscript 2. If I have
I have a project that adds elements to an AutoCad drawing. I noticed that
We manage a site for a medical charity. They have a number of links
Let say I have the following desire, to simplify the IConvertible's to allow 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.