Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8520623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:35:09+00:00 2026-06-11T06:35:09+00:00

I have made an android application where image will save to local database when

  • 0

I have made an android application where image will save to local database when the network is unavailable. I am keeping image uri inside database table and retrieving image from image uri and showing that image on imageView of a listView using Custom array adapter. When I am running my application with emulator, it is working well. However while using an android mobile phone it showing Forced Close error.

The error log is given below:

java.lang.OutOfMemoryError: bitmap size exceeds VM budget
at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:504)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:370)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:715)
at android.graphics.drawable.Drawable.createFromStream(Drawable.java:675)
at android.widget.ImageView.resolveUri(ImageView.java:525)
at android.widget.ImageView.setImageURI(ImageView.java:309)
at com.freedom.net.Syncho2$NoteListAdapter.getView(Syncho2.java:219)
at android.widget.AbsListView.obtainView(AbsListView.java:1519)
at android.widget.ListView.makeAndAddView(ListView.java:1749)
at android.widget.ListView.fillDown(ListView.java:674)
at android.widget.ListView.fillFromTop(ListView.java:731)
at android.widget.ListView.layoutChildren(ListView.java:1602)
at android.widget.AbsListView.onLayout(AbsListView.java:1349)
at android.view.View.layout(View.java:7320)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1263)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1137)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1051)
at android.view.View.layout(View.java:7320)
at android.widget.FrameLayout.onLayout(FrameLayout.java:342)
at android.view.View.layout(View.java:7320)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1263)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1137)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1051)
at android.view.View.layout(View.java:7320)
at android.widget.FrameLayout.onLayout(FrameLayout.java:342)
at android.view.View.layout(View.java:7320)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1162)

MY Custom adapter is given below:

public class NoteListAdapter extends  ArrayAdapter<ImageFromDB> {
Context c;

ArrayList<ImageFromDB> image = null;
ArrayList<String> uriImage = null;
ArrayList<Integer> ID = null;

private AllId allid = null;
DBAdapter db = null;

WatchListAllEntity watchListAllEntity=null;
int flagVariable=1;
private ArrayList<ImageFromDB> items;

public NoteListAdapter(Context context, int textViewResourceId,
        ArrayList<ImageFromDB> items) {

    super(context, textViewResourceId, items);
    Log.e("sf","123");
    this.items = items;
    c=context;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView;

    final int myPosition = position;
    if (v == null) {
        LayoutInflater vi = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        v = vi.inflate(R.layout.listitempict2, null);
    }
    ImageFromDB re = items.get(position);
    Log.e("re", re+"");
    if (re != null) {
        ImageView tt = (ImageView) v.findViewById(R.id.imageviewproduct);
        String imageUri = re.getImageuri();
        Log.e("imageUri", imageUri+"");
        tt.setImageURI(Uri.parse(imageUri));

        final CheckBox checkBox = (CheckBox) v.findViewById(R.id.checkboxproduct);
        checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            public void onCheckedChanged(CompoundButton buttonView,
                    boolean isChecked) {

                if (isChecked) {
                    if(flagVariable==1)
                    {
                        String ImUri = items.get(myPosition).getImageuri();
                        allid.setImageUri(ImUri);
                        allid.setId(items.get(myPosition).getId());
                        flagVariable++;
                        Log.e("flagVariable  : " , flagVariable+"");
                    }
                    else
                    {
                        checkBox.setChecked(false);
                        //Toast.makeText(Syncho2.this,"正しく選んでください。",Toast.LENGTH_SHORT).show();
                    }
                } else {
                    flagVariable=1;
                    Log.e("flagVariable  : " , flagVariable+"");
                }
            }
        });
    }
    return v;
}
}

I am calling this Adapter from a activity like this:

noteListAdapter = new NoteListAdapter(this, R.layout.listitempict, image);

I noticed from debug, the Adapter is being called six times when the image is only two . Five times it’s returning a view but on the sixth time it is showing that error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T06:35:10+00:00Added an answer on June 11, 2026 at 6:35 am

    I have found a solution . I thing everybody should know about memory management of android application. http://www.youtube.com/watch?v=_CruQY55HOk . When I am trying to show image Uri directly on ImageView then the problem is creating . I thing everybody should avoid code like this ImageView.setImageURI(Uri.parse(imageUri)) . Instead of that, try to load bitmap or drawable on imageview.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the XMPP Connection(using smack) for chat in android application.I have made
I have made an application in android that lets the user compress and decompress
i have made an android application for Project Build Target as Target name:: Android
I am making the phonegap android application in html,javascript and jquery.I have made the
I have a little problem... I have made an Android application which extends the
I have made a ListView in my android application. But the problem is that
I have made an android application in which there is a text and button
i have made an android application and in it , there is one scenario
I have made a Android streaming application that plays media from online URL's. For
i made android application. In application i have web view where i want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.