Reputation: 1856
I have Database, where I have 3 columns (first Id
,second title String
, third image int
). DB like contact list with photo.
ContentValues cv = new ContentValues();
cv.put(COLUMN_TITLE, "John");
cv.put(COLUMN_IMG_OUTSIDE, R.drawable.john_photo);
db.insert(DB_TABLE, null, cv));
Then with SimpleCursorAdapter
I fill the list from names and their photo
SimpleCursorAdapter scAdapter;
String[] from = new String[] { DataBase.COLUMN_IMG_OUTSIDE,DataBase.COLUMN_TITLE};
int[] to = new int[] { R.id.img, R.id.text1, };
cursor = db.getAll();
startManagingCursor(cursor);
scAdapter = new SimpleCursorAdapter(ListOfItems.this, R.layout.list, cursor, from, to);
listView.setAdapter(scAdapter);
All is work, but when i want to add record to DB and choose a picture from Galery, i don't know how to save it in DB. I think i can save path to file like String path = "/sdcard/DCIM/Camera/IMG20130222_008.jpg"
; But it is proble when i will fill list, becouse in DB image is saving like integer value. Sorry for my english =(
Upvotes: 0
Views: 503
Reputation: 1065
Maybe you should try to save the whole image into db as blob?
See Android How to save camera images in database and display another activity in list view?
In this case you have to write your own CursorAdapter, then see this
Images in SimpleCursorAdapter
Upvotes: 1