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

  • Home
  • SEARCH
  • 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 7601717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:13:57+00:00 2026-05-30T23:13:57+00:00

I have a SQlite database with some columns and with a content of an

  • 0

I have a SQlite database with some columns and with a content of an EditText I would like to select some rows from the database.

In main activity:

case R.id.betx:

        String dates2 = sqletx.getText().toString();
        GlobalVars.settables(dates2);
        Intent intentstar2t = new Intent(dbhelp.this, CustomList.class);
            startActivity(intentstar2t);
        break;

This is my main activity, the ‘dates2’ String is the content of the edittext, and I save it for the setTables method.

My code in the hornot class where:

 public Cursor getTable() {         
 String deda = GlobalVars.gettables();
 String[] columns = new String[]{KEY_ROWID, KEY_NAME, KEY_HOTNESS,
 KEY_CALORIE, KEY_MULTI, KEY_DATE};             
 return ourDatabase.query(DATABASE_TABLE, columns, KEY_DATE + "=" + deda ,
 null, null, null, null);
            }

Here I create a Cursor for the rows that fulfill the requirements in the last row. The String deda will be the ‘dates2’ we set before and I would like to get the rows where the KEY_DATE is equivalent to dates2.

The listview activity where I list the suitable rows.

 if (todoItems.size() > 0) {
                 todoItems.clear();  
             }
          if (list.size() > 0) {
             list.clear();   
         }
          Cursor c = info.getTable();
          c = info.getTable();
             if (c.moveToFirst())
             {
             do{
                 todoItems.add(c.getString(0) + " " + c.getString(1) + " " + c.getString(2)+ " " + c.getString(3)+ " " + c.getString(4));
                                 quanitems.add(c.getString(4));
                             }
             while (c.moveToNext());
             }


             if (todoItems.size() > 0)
             {

                 for (int i=0; i<todoItems.size(); i++)
                 {

                     each=new EachRow();
                     each.text=(String) todoItems.get(i);
                     list.add(each);
                     each2=new EachRow();
                     each2.text=(String) quanitems.get(i);
                     list2.add(each2);

                 }
                 listView.setAdapter(new MyAdapter(this, 0, list)); 
             }

I use a custom listview, in every row there are some items, but the point is that I create a cursor (c) for the rows where the KEY_DATE is equivalent to dates2.

My problem is I never define integer variable here, but if I create an entry where the date is for example “107” or “6519684” it is working, but if it is “tableOne” or any text it crushes at the row:

return ourDatabase.query(DATABASE_TABLE, columns, KEY_DATE + "=" + deda , null, null, null, null);

and

Cursor c = info.getTable();

(as you can see both problems are connected to the getTable method.

I use only Strings so practically the numbers (“107”) are strings as well.

Any idea?

Thanks in advance!

  • 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-30T23:13:58+00:00Added an answer on May 30, 2026 at 11:13 pm

    use:
    return ourDatabase.query(DATABASE_TABLE, columns, KEY_DATE + "=?" ,
    new String[] { deda }, null, null, null);

    Edit(explaination):

    in query method you have String selection and String[] selectionArgs parameters, so in selection you can use ? for parameters in selectionArgs. Now underlying query builder will build query with this paramater and will apply proper escape chars.

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

Sidebar

Related Questions

I have an sqlite database, and I would like to keep it read-only without
I have an SQLite database in which some columns are date-time strings with the
I have an Android SQLite Database and I inserted some rows. After I deleted
I have made the following code to retrive data from SQLite database. public Cursor
In my iPhone app, I have created index on Sqlite database table for some
I have a listview which loads its data from sqlite database. Each row in
I have a SQLite database of notes that have columns _id, title, details, listid
I have a description column in my SQLite database that contains some text to
I have a SQLite database with a table containing the scores of some league
I have an sqlite database full of huge number of URLs and it's taking

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.