i want to make images backup because of this i use sqlite DataBase for storing images my code is worked fine when i put 10 to 12 images but after that it shows OutOfMemoryError . i use android:largeHeap="true" it increase some amount of memory but this is not sufficient for my work.how can i solve this??please help me guys.
this is my code:
if(data==null){
Uri uri = data.getData();
try {
InputStream inputStream = getContentResolver().openInputStream(uri);
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
Bitmap bmp = BitmapFactory.decodeStream(bufferedInputStream);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, bos);
byte[] bArray = bos.toByteArray();
DataBase dataBase=new DataBase(getBaseContext());
dataBase.insertImage(bArray);
Toast.makeText(getBaseContext(),"single item ",Toast.LENGTH_LONG).show();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Aucun commentaire:
Enregistrer un commentaire