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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:55:22+00:00 2026-06-04T18:55:22+00:00

I am able to query the Android MediaStore but I cannot setup the where

  • 0

I am able to query the Android MediaStore but I cannot setup the “where” statement. So I gave up on trying to get it and tried to hack around it and my hack also doesn’t work.

My hack is to move through each row of my cursor and see if the string value of the column I’m interested in is equivalent to my search keyword… My code is below. What I am trying to do is find all songs in an album (or artist, playlist).

Would appreciate any help setting up the Query for “where” or why my string comparison isn’t working…

private void loadList() {

        String selection = ((HashMap<String, String>) selectedAlbumData.get(0))
                .get("Album").toString();

        String[] proj = { MediaStore.Audio.Media._ID,
                MediaStore.Audio.Media.DISPLAY_NAME,
                MediaStore.Audio.Media.DATA, MediaStore.Audio.Media.ARTIST,
                MediaStore.Audio.Media.ALBUM, MediaStore.Audio.Media.DURATION };

        // managed query doesn't need startManagingCursor called on the
        Cursor c = managedQuery(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
                proj, null, null, null);

        if (c.getCount() < 1) {
            Log.d("AFA", "Cursor query is empty.. :( ...");
        } else {

            // do stuff with our content...
            while (c.moveToNext()) {

                HashMap<String, String> temp = new HashMap<String, String>();

                if (c.getString(c.getColumnIndex(MediaStore.Audio.Media.ALBUM)) == selection) {

                            //do stuff with this data

                }
                Log.d("SongChoosing", "C str is: " + c.getString(c.getColumnIndex(MediaStore.Audio.Media.ALBUM)));
            }

            //debug stuff
            c.moveToPosition(5);
            Log.d("SongChoosing", "Selection is: " + selection);
            Log.d("SongChoosing", "C str is: " + c.getString(c.getColumnIndex(MediaStore.Audio.Media.ALBUM)));
        }
    }

The string value I’m looking for in the albums column is a valid string, its not null or empty.. I tried printing every row of my songs on the log cat and the strings look equivalent to the naked eye but my if statement isn’t working…

Thanks a ton to anyone who can help me.

  • 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-04T18:55:24+00:00Added an answer on June 4, 2026 at 6:55 pm

    You have to use equals or equalsIgnoreCase instead of == with strings.

    Try this

     if (c.getString(c.getColumnIndex(MediaStore.Audio.Media.ALBUM)).equalsIgnoreCase(selection)) {
    
                            //do stuff with this data
    
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm querying MediaStore.Images.Media.EXTERNAL_CONTENT_URI and the query works fine. I'm able to get the data
I'm trying to learn LINQ to SQL and I'm able to query the database
I am trying to update cached_name column of callog.calls table in android,but getting sql
I need to be able to query a SharePoint database for survey results. The
What privileges do you need to be able to query the sys.obj$, sys.col$ etc
i have some apache logs and i want to be able to query the
I am currently able to export my MySQL query to a tab delimited text
I need to be able to run an Oracle query which goes to insert
I need to be able to have an SQL query that searches my database
I am not able to run a simple select query with a where clause.

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.