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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:06:58+00:00 2026-06-18T09:06:58+00:00

I got a searching function inside my app. It works almost properly, my problem

  • 0

I got a searching function inside my app.
It works almost properly, my problem is it is only catching results that similiar to the searchWord from the begining.

For example:
If searchWord is “ada”, the results will be contains all the records that START WITH “ada” but not those that contains “ada” somewhere inside them.

I know it must be just a little modification but this is the first piece of database handling i ever did.

So how must i modify this to search for any contains, and not for starts with?

code:

public Cursor getMatchingFromContacts(String searchWord) throws SQLException {

    String queryString = "SELECT _id, full_name FROM "
            + SF_CONTACT_TABLE;

    if (searchWord != null) {
        searchWord = searchWord.trim() + "%";
        queryString += " WHERE " + FULL_NAME + " LIKE ?";
    }
    String params[] = { searchWord };

    if (searchWord == null) {
        params = null;
    }
    try {
        Cursor cursor = db.rawQuery(queryString,
                params);
        if (cursor != null) {
            cursor.moveToFirst();
            return cursor;
        }
    } catch (SQLException e) {
        Log.e("AutoCompleteDbAdapter", e.toString());
        throw e;
    }

    return null;
}
  • 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-18T09:06:59+00:00Added an answer on June 18, 2026 at 9:06 am

    Just modify your block here:

    if (searchWord != null) {
        searchWord = "%" + searchWord.trim() + "%";
        queryString += " WHERE " + FULL_NAME + " LIKE ?";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been searching for this on google en SO, i got the function that
Got a problem that seems to be fairly endemic with IE8 (searching on Google)
I've got a recursive function searching an object by index in a multidimensional, associative
I’ve got a function that appends a <div> to an element on click. The
i got a n00b problem with python and i've been searching here for a
I have this function I am using to decrypt values that works fine on
I've got this code that uses a str_replace function: $result = mysql_query(SELECT * FROM
I'm working on a simple image tagging and searching app. I've got my images
i got a little problem with searching my database and outputting the data. This
So, I've got a function that loads up a char** variable with some string

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.