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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:44:04+00:00 2026-05-21T12:44:04+00:00

I am working on a database with sqllite in an android app I want

  • 0

I am working on a database with sqllite in an android app
I want to retrieve sm data using a like clause
ex:

Cursor c = myDB.query(MY_DATABASE_TABLE, null, " SongName LIKE '%"+"=?"+"%'" , 
           new String[]{match_str}, null, null,"SongHit  DESC");

It should give all SongName starting with match_str but its not working.Why?

  • 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-05-21T12:44:04+00:00Added an answer on May 21, 2026 at 12:44 pm

    This:

    " SongName LIKE '%"+"=?"+"%'"
    

    Will end up looking like this when the SQL interpreter sees it:

    " SongName LIKE '%=?%'"
    

    And that will match any SongName that contains a literal “=?” and I don’t think that’s anything like what you want.

    A % matches any sequence of characters in an SQL LIKE, it is essentially the same as .* in a regular expression; so, if you want to match at the beginning then you don’t want a leading %. Also, your ? placeholder needs to be outside the single quotes or it will be interpreted as a literal question mark rather than a placeholder.

    You want something more like this:

    String[] a = new String[1];
    a[0]       = match_str + '%';
    Cursor   c = myDB.rawQuery("SELECT * FROM songs WHERE SongName LIKE ?", a);
    

    If you wanted to be really strict you’d also have to escape % and _ symbols inside match_str as well but that’s left as an exercise for the reader.

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

Sidebar

Related Questions

I am working with sqlite database. I retrieve text data from sqlite database into
I am working on I Phone app, In that I am using SQLITE database.
I am working on an android app in which I am using some Native
I'm working on my first android app and have an SQLite database set up
I'm working on an Android application that stores data in a SQLite database. My
I'm using ORMLite & SQLite as my database, and I'm working on a android
i'm working on an iPhone application which retrieve sqlite database from server through json/rest
I'm working some code that inserts csv rows into an SQLite database using Python.
I have been working with iPhone application in which i am using sqlite database.
I am working on Android database type application. We need to show some reports.

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.