0
bytearray를 비트 맵으로 변환하려고 할 때 null이 나타납니다. 나는 이유를 모른다. 나에게 유용한 제안을 해주세요.데이터베이스에서 이미지 검색
super.onCreate(savedInstanceState);
setContentView(R.layout.newscreen);
TextView name = (TextView)findViewById(R.id.textView1);
TextView age = (TextView)findViewById(R.id.textView2);
ImageView img = (ImageView)findViewById(R.id.imageView1);
db = openOrCreateDatabase(
"StudentData.db"
, SQLiteDatabase.CREATE_IF_NECESSARY
, null
);
db.setVersion(1);
db.setLocale(Locale.getDefault());
db.setLockingEnabled(true);
Cursor cur = db.query("stuData",
null, null, null, null, null, null);
//cur.moveToFirst();
cur.moveToFirst();
//name.setText(cur.getString(1));
//age.setText(cur.getString(2));
// if(bb!=null)
//{
//ByteArrayInputStream imageStream = new ByteArrayInputStream(bb);
//bs = new BufferedInputStream(bb)
//img.setImageBitmap(theImage);
while (cur.isAfterLast() == false) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize=5;
name.append("n" + cur.getString(1));
byte[] bb = cur.getBlob(3);
System.out.print("DAta"+bb);
for(int i =0;i<bb.length;i++)
{
System.out.println(bb[i]);
}
Bitmap theImage = BitmapFactory.decodeByteArray(cur.getBlob(3),0,cur.getBlob(3).length);
img.setImageBitmap(theImage);
cur.moveToNext();
}
cur.close();
@Vladimir와 완전히 동의합니다. 21 개의 질문 중 하나라도 좋은 답변을받지 못했다면 왜 계속 묻는 지 궁금합니다. – Adinia