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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:03:36+00:00 2026-06-05T03:03:36+00:00

I’m getting an ExceptionInitializerError on the following line of code: (Activity 1) Activity2.selection =

  • 0

I’m getting an “ExceptionInitializerError” on the following line of code:

(Activity 1)

Activity2.selection = AudioColumns.ARTIST + "=?";

(Activity 2)

static String selection;

Could someone please tell me what I’m doing wrong?

For complete code, see below.

(Activity 1)

package awesome.music.player;

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.BaseColumns;
import android.provider.MediaStore;
import android.provider.MediaStore.Audio.AlbumColumns;
import android.provider.MediaStore.Audio.ArtistColumns;
import android.provider.MediaStore.Audio.AudioColumns;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;

public class ArtistsActivity extends Activity implements OnItemClickListener {

    private Cursor artistCursor;

    @SuppressWarnings("deprecation")
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.artistsview);

        String[] artistColumns = { BaseColumns._ID, ArtistColumns.ARTIST };
        // The columns to return for each row.

        artistCursor = managedQuery(
                MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI, artistColumns,
                null, null, null);

        ListView listView = (ListView) findViewById(R.id.listViewArtists);
        listView.setOnItemClickListener(this);
        // set an on item click listener to the first list view in this activity

        String[] displayFields = new String[] { ArtistColumns.ARTIST };
        // set all the artist names to the array "displayfields"
        int[] displayViews = new int[] { R.id.artistTitle };
        // number of rows to display and where to bind them

        SimpleCursorAdapter artistAdapter = new SimpleCursorAdapter(this,
                R.layout.artistitem, artistCursor, displayFields, displayViews);
        listView.setAdapter(artistAdapter);
    }

    // Take the display fields array, and bind to the matching display row

    public void onItemClick(AdapterView<?> a, View v, int position, long id) {
        if (artistCursor.moveToPosition(position)) {

            Playlist.selection = AudioColumns.ARTIST + "=?";

            Playlist.selectionArgs = new String[] { artistCursor
                    .getString(artistCursor.getColumnIndex(AlbumColumns.ARTIST)) };

            Playlist.artist = artistCursor.getString(artistCursor
                    .getColumnIndex(ArtistColumns.ARTIST));

            Intent intent = new Intent(ArtistsActivity.this,
                    ArtistAlbumsActivity.class);

            startActivity(intent);

        }
    }

}

(Activity 2)

package awesome.music.player;

import java.util.ArrayList;

import android.content.ContentUris;
import android.net.Uri;

public class Playlist {

    static ArrayList<String> pathList = new ArrayList<String>();
    static ArrayList<String> artistList = new ArrayList<String>();
    static ArrayList<String> albumList = new ArrayList<String>();
    static ArrayList<String> titleList = new ArrayList<String>();
    static ArrayList<String> idList = new ArrayList<String>();
    static ArrayList<String> durationList = new ArrayList<String>();

    static int currentSongIndex;
    static String currentSongPath;
    static String artist;
    static String album;
    static String albumId;
    static String numSongs;
    static String selection;
    static String[] selectionArgs;
    static String totalSongduration; // Set

    static String songDuration = durationList.get(currentSongIndex);

    static String currentAlbumId = Playlist.idList
            .get(Playlist.currentSongIndex);

    static Integer currentAlbumIdLong = Integer.parseInt(currentAlbumId);

    static Uri artworkUri = Uri
            .parse("content://media/external/audio/albumart");

    static Uri currentSongUri = ContentUris.withAppendedId(artworkUri,
            currentAlbumIdLong);;

    static int totalSongDuration = Integer.parseInt(songDuration);

}

Thanks for your help.

  • 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-05T03:03:37+00:00Added an answer on June 5, 2026 at 3:03 am

    Dont use Static its a bad habit, Instead using “static” make an Object the class and use it.

    public class Playlist {
    
        ArrayList<String> pathList = new ArrayList<String>();
    ....
    ...
    }
    

    Implementing.

    public class ArtistsActivity extends Activity implements OnItemClickListener {
    
        private Playlist mPlaylist;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            setContentView(R.layout.artistsview);
            mPlaylist= new Playlist();
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
Specifically, suppose I start with the string string =hello \'i am \' me And
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.