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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:38:05+00:00 2026-06-15T17:38:05+00:00

I have a precompiled database and I want to get the data according the

  • 0

I have a precompiled database and I want to get the data according the passed parameters

But for some strange reason the cursor results always empty

My getData method in the adapter is

    public Cursor getData(String uso, String eta, String category,
            String class) {
        try {
            Cursor c;
            if (class.equals(null) && category.equals(null)) {
                c = mDb.rawQuery("SELECT * FROM dbtable WHERE Uso LIKE \""
                        + uso + "\" AND Eta LIKE \"" + eta
                        + "\" AND Language LIKE \"" + language
                        + "\" order by Name asc", null);
            } else if (class.equals(null)) {
                c = mDb.rawQuery("SELECT * FROM dbtable WHERE Uso LIKE \""
                        + uso + "\" AND Eta LIKE \"" + eta
                        + "\" AND Tipo LIKE \"" + category
                        + "\" AND Language LIKE \"" + language
                        + "\" order by Name asc", null);
            } else if (category.equals(null)) {
                c = mDb.rawQuery("SELECT * FROM dbtable WHERE Uso LIKE \""
                        + uso + "\" AND Eta LIKE \"" + eta
                        + "\" AND Certification LIKE \"" + class
                        + "\" AND Language LIKE \"" + language
                        + "\" order by Name asc", null);
            } else {
                c = mDb.rawQuery("SELECT * FROM dbtable WHERE Uso LIKE \""
                        + uso + "\" AND Eta LIKE \"" + eta
                        + "\" AND Tipo LIKE \"" + category
                        + "\" AND Certification LIKE \"" + class
                        + "\" AND Language LIKE \"" + language
                        + "\" order by Name asc", null);
            }
            if (c != null) {
                c.moveToNext();
            }
            return c;
        } catch (SQLException mSQLException) {
            Log.e(TAG, "getDataCar >>" + mSQLException.toString());
            throw mSQLException;
        }

    } 
...

This cursor is used in a method that puts all entries in an array of Car objects

public Car[] getDataDBCarsArray(String uso, String eta,
            String category, String class) {
        ArrayList<Car> list = new ArrayList<Car>();
        Cursor c = getData(uso, eta, category, class);
        try {
.....

All works fine If instead of the above getData(….) I try to use

public Cursor getAllData(){
    try {
        Cursor c = mDb.rawQuery("SELECT * FROM dbtable order by Name asc", null);
        if (c != null) {
            c.moveToNext();
        }
        return c;
    }catch (SQLException mSQLException) {
        throw mSQLException;
    }

}

so seems a problem with the query in getData(…).

But I cannot figure where is the error.

If I try to open the database there are many elements for the passed parameters but strangely doesn’t find anything.

NB

language is a static value that depends by the device language

  • 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-15T17:38:06+00:00Added an answer on June 15, 2026 at 5:38 pm

    You have forgotten the SQL wildcards…

    This:

    WHERE column = "John"
    

    Is the same as:

    WHERE column LIKE "John"
    

    You want to incorporate % and _ wildcards to create a clause like:

    WHERE column LIKE "%John%"
    

    Also you should take advantage of SQLite parametrization and protect yourself from SQL injection attacks:

    c = mDb.rawQuery("SELECT * FROM dbtable " + 
            "WHERE Uso LIKE ? AND Eta LIKE ? AND Language LIKE ? ORDER BY Name",
            new String[] { "%" + uso + "%", 
                           "%" + eta + "%", 
                           "%" + language + "%" });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application on ASP.NET (C#) that has some precompiled components. I've
I have precompiled my application but every 10 - 30 min it unloads then
I have installed MySqldb through .exe(precompiled). Its is stored in site-packages. But now i
Referring here A is a precompiled Java class (I also have the source file)
I have website on the server, which is not precompiled (with source code, so
I'm currently trying to learn ACSL, a precompiled language for Fortran, and have found
I'm a bit confused to what it actually means to have precompiled Handlebar.js templates
I have a precompiled object file, say myObjectFile.o. Inside my .pro file I have
I have OS X 10.5 set up with the precompiled versions of PHP 5
I have a C header file that I have precompiled using the gcc -E

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.