안드로이드 개발 질문/답변
(글 수 45,052)
어제 부터 계속 이것만 붙잡고 있내여..
검색해서 찾아보니 여러 몇가지 단서는 찾은거 같은데 단서가 맞는건지도 모르겠고 잘 안됩니다..
db에 bitmap을 정장해서 불러오고 싶은데 아무리 찾아도 방법을 모르겠습니다..ㅜ
//저장 부분
ContentValues row;
row = new ContentValues();
row.put("A", "에이");
row.put("B", "비");
row.put("C","씨");
db.insert("abc", null, row);
//불러내는 부분
Cursor cursor = db.rawQuery("SELECT * FROM abc ORDER BY input_order DESC", null); //대충 이런식으로..
이런식으로 문자열 저장하고 불러오는 건 했습니다..
하지만 bitmap 을 저장해서 불러오려니 도저히 모르겠습니다
도와주세요..
2011.06.23 16:55:08
Bitmap bit = BitmapFactory.decodeResource(getBaseContext().getResources(), R.drawable.icon);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bit.compress(CompressFormat.JPEG , 100 , stream);
byte[] b = stream.toByteArray();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bit.compress(CompressFormat.JPEG , 100 , stream);
byte[] b = stream.toByteArray();
ContentValues row;
row.put("photo", b);
db.insert("test", null, row);
이런식으로 저장을 시도 했는데여.. 저장이 안되는거 같아여 ㅠ
db.execSQL("CREATE TABLE test ( _id INTEGER PRIMARY KEY AUTOINCREMENT, " +
" photo BLOB);");
db는 이런식으로 했고요..




bitmap을 byte배열로 얻으신 다음에 blob 형태로 저장하시면 됩니다.