Using parse.com and having allocation memory issue

蓝咒 提交于 2019-12-02 07:38:18

If you are using parse.com and getting the Images from database and converting it to bitmaps it will crash your app..

what you should do is, get the image of the URL from parse.com there is method called..

 ParseFile.getUrl(); 

For that implement the Picasso library, which is perfect solution for loading images from database.

To implement picasso in your app,

compile 'com.squareup.picasso:picasso:2.5.2'

Then get the file from parse database

ParseFile file = getParseFile("ImageColumn");

To load the file

Uri url = Uri.parse(file.getUrl());

then just get context and ..add following passing your file url..

Picasso.with(context)
   .load(url)  //load from your URL of parseFile
   .into(imageView);  //set it to your ImageView

Here is the reason, why you should implement this..

Getting Bitmap file will consume so much memory, and it will give you OutOfMemory Exception, which you are getting right now. So instead you just get the URL of file and that's it. Loading image will be dependent on the Internet. so you are saving the memory by not converting every single bit into image. Also you will do in loop for every image will cause your app to crash.

ALSO full tutorial will be available from Official website Picasso Library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!