私は画像配列とそれに対応するタイトルを持っています:
int [] landmarkImages={R.drawable.oblation,R.drawable.eastwood,R.drawable.ecopark,R.drawable.circle};
String []landmarkDetails = { "Oblation", "Eastwood", "Ecopark", "QC Circle"};
私はビットマップ機能を使用するのが初めてで、これに対処する方法がわかりません。アクティビティ フォースが停止し、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!");
}