Reputation: 6553
I have an application that draws a lot of graphics and change them. Since I have many graphics, I thought of having the images outside the APK, downloaded from the internet as needed, and saved on the files application folder.
But I started to get outOfMemory exceptions.
The question is: Does android handle memory different if I load a graphic from APK than if I load it from 'disk'?
code using APK:
topView.setBackgroundResource(R.drawable.bg);
code if image is outside APK:
Drawable d = Drawable.createFromPath(pathName); topView.setBackgroundDrawable(d);
Thanks
Daniel
Upvotes: 1
Views: 902
Reputation: 11313
At runtime, the memory footprint you're seeing should be about the same no matter which way you load it. Android will use a utility to byte-align resources internal to the apk which should improve loading times.
Upvotes: 0
Reputation: 296
No, internally they are handled the same. Most likely, you're leaking the images, or not cleaning them up as quickly as you could. Try calling Bitmap.recycle();
once you're done with an image, to force Android to clean it up.
Upvotes: 3