我有一个图像数组及其对应的标题:
int [] landmarkImages={R.drawable.oblation,R.drawable.eastwood,R.drawable.ecopark,R.drawable.circle};
String []landmarkDetails = { "Oblation", "Eastwood", "Ecopark", "QC Circle"};
我是使用Bitmap功能的新手,我不知道如何处理这个问题。 Activity强制停止并显示 java.lang.OutofMemoryError 现在我想将它们插入我的sqlite数据库,但是我在这一行收到错误:
Bitmap image = BitmapFactory.decodeResource(getResources(),
landmarkImages[loaded]);
以下是它所在的方法:
Log.d("Insert: ", "Inserting ..");
for(int loaded=0; loaded <=landmarkDetails.length;loaded++){
Bitmap image = BitmapFactory.decodeResource(getResources(),
landmarkImages[loaded]);
// convert bitmap to byte
ByteArrayOutputStream stream = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byte imageInByte[] = stream.toByteArray();
Log.d("Going to load images", "Image "+ loaded);
Log.d("Goind to load objects", "loading");
int ctr = db.checkContact(landmarkDetails[loaded]);
if(ctr == 0){
Log.d("Nothing Loaded", "Loading Now");
db.addContact(new Contact(landmarkDetails[loaded], imageInByte));}
Log.d(landmarkDetails[loaded], "Loaded!");
}