Reputation: 59
I am new to android so have very less idea about working of images in sqlite db. I am creating an app in which i will be creating a db with pre-filled data that means i would be putting that data-filled db in assets folder and user will start using it directly once the app is installed. So i have around 186 images of flags from different countries, which i need to show in a custom listview. Can you tell me how to store all images in sqlite db and get it back to show on listview? I tried using some IDE for inserting images in db but their decoding doesn't work. Please help!!!
Upvotes: 0
Views: 360
Reputation:
try this First of all you have to store all images in blob datatype into sqlite database then for retrieving from database user following code
query_compnay_id="Select * From "+mStaticValues.company_master;
mCursor_company_detail=mDatabaseConnectionAPI.ExecuteQueryGetCursor((query_compnay_id));
mCursor_company_detail.moveToFirst();
byte[] by =mCursor_company_detail.getBlob(mCursor_company_detail.getColumnIndex(mStaticValues.image_data));
mBitmap=BitmapFactory.decodeByteArray(by, 0, by.length, null);
Upvotes: 1