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 9041339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:13:02+00:00 2026-06-16T10:13:02+00:00

Here i have created expandable list view which is having group row for Artist

  • 0

Here i have created expandable list view which is having group row for Artist and in child it shows all albums for artist with album art. But It throws out of memory exception.

Here Is my code to get the Image :

public static Bitmap getArtwork(Context context, int album_id) {

        ContentResolver res = context.getContentResolver();
        Uri uri = ContentUris.withAppendedId(sArtworkUri, album_id);
        if (uri != null)
        {
            InputStream in = null;
            try 
            {
                in = res.openInputStream(uri);
                return BitmapFactory.decodeStream(in, null, sBitmapOptions);
            } catch (FileNotFoundException ex) 
            {
                // The album art thumbnail does not actually exist. Maybe the user deleted it, or
                // maybe it never existed to begin with.
            } finally
            {
                    if (in != null)
                    {
                        try
                        {
                            in.close();
                        } catch (IOException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }
                }
             }
        return null;
    }

And for creating child album list i have done this :

private ArrayList<ArrayList<HashMap<String, Object>>> createChildList() {
    for (int i = 0; i < songsListData.size(); i++) 
    {

        ArrayList<HashMap<String,Object>> secList = new ArrayList<HashMap<String,Object>>();
        String s[] = new String[]{songsListData.get(i).get("artistname")};
        String whereClause = MediaStore.Audio.Albums.ARTIST + " = ? ";

        Cursor cursor = managedQuery(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI,null ,whereClause,s,null);

        if (cursor == null) 
        {
              //Query Failed , Handle error.
        }
        else if (!cursor.moveToFirst()) 
        {
             //No media on the device.
        }
        else
        {            
              int albumName = cursor.getColumnIndex(MediaStore.Audio.Albums.ALBUM);
              int id = cursor.getColumnIndex(MediaStore.Audio.Albums._ID);
              int songcount = cursor.getColumnIndex(MediaStore.Audio.Albums.NUMBER_OF_SONGS);

              for(int j=0;j<cursor.getCount();j++)
              {
                    String Name = cursor.getString(albumName);
                    Integer albumid = cursor.getInt(id);                        
                    Bitmap bitmap = null;
                    bitmap = getArtwork(context, albumid); //calling function
                    if(bitmap == null)
                    {
                        bitmap = BitmapFactory.decodeResource(context.getResources(),R.drawable.wallpaper);
                    }   
                    HashMap<String, Object> album = new HashMap<String, Object>();
                    album.put("albumName",Name);
                    album.put("albumId", albumid);  
                    album.put("image", bitmap);  //storing image
                    album.put("songcount",cursor.getString(songcount) + " song");
                    secList.add(album);
                    cursor.moveToNext();
               }                  
           }
           cursor.close();   
           albumData.add(secList);
    }
    return albumData;
}

what should i do to handle out of memory exception.?? Pleaze give me some solution. Thanx.

  • 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-16T10:13:04+00:00Added an answer on June 16, 2026 at 10:13 am

    Debug your code and trace heap size when it goes unexpectedly up
    that must be due to increase image Size
    you can use the Document to Get an idea that how Android calculate the Image Size

    public static Bitmap getResizedBitmap(Bitmap image, int newHeight, int newWidth) {
        int width = image.getWidth();
        int height = image.getHeight();
        float scaleWidth = ((float) newWidth) / width;
        float scaleHeight = ((float) newHeight) / height;
        // create a matrix for the manipulation
        Matrix matrix = new Matrix();
        // resize the bit map
        matrix.postScale(scaleWidth, scaleHeight);
        // recreate the new Bitmap
        Bitmap resizedBitmap = Bitmap.createBitmap(image, 0, 0, width, height,
                matrix, false);
        return resizedBitmap;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to take an expandable list view that I have already created
Overview: I have an Expandable List View which displays items of the type ToDoElement
Here I have created a website in c#.net and I want the page which
From here I have created a BaseForm , then set all its BaseForm.Designer.cs private
I am trying to create an expandable list view like the one described here
I have created one UIImageView Here's code capView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:kARROW_CAP_NAME]]; capView.frame
I have created a dropdown menu with jquery: here Everything is ok but in
I have created my web socket server and client using this simple tutorial here
I have created a drop down with jQuery that can be seen here by
I have created a jsfiddle of my problem. Here is a link to the

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.