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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:37:56+00:00 2026-06-16T19:37:56+00:00

I want to display only those rows which has date equal to my String

  • 0

I want to display only those rows which has date equal to my String from getdate(string data) function, so I tried to change working function which was displaying all entries from database in a Listview with SELECT from … command but it didn’t work.
How can I get those events from my calendar?

My whole database code

Working corectly function:

public Cursor getAllContacts() 
{
    return database.query("calendar_events", new String[] {"_id", "event"}, 
     null, null, null, null, "date");
}

I wanted to change it to:

public Cursor getdate(String data){
    return database.rawQuery("SELECT event FROM calendar_events WHERE date = '" + data + "'", new String[] { "event"});
}

fragment of the function where I changed : getAllContacts( code was working corectly and displaying events from calendar in a List view, after clicking on it I can enter into all data from this database entry) to getdate(“2012-12-30”):

 private class GetContacts extends AsyncTask<Object, Object, Cursor> 
{
   DatabaseConnector dbConnector = new DatabaseConnector(DayPlan.this);

   @Override
   protected Cursor doInBackground(Object... params)
   {
      dbConnector.open();
      return dbConnector.getdate("2012-12-30"); 
   } 

   @Override
   protected void onPostExecute(Cursor result)
   {
      conAdapter.changeCursor(result); // set the adapter's Cursor
      dbConnector.close();
   } 
}

the whole code from this class:

Error I’m having:

01-02 14:32:13.828: E/AndroidRuntime(809): FATAL EXCEPTION: AsyncTask #1
01-02 14:32:13.828: E/AndroidRuntime(809): java.lang.RuntimeException: An error occured while executing doInBackground()
01-02 14:32:13.828: E/AndroidRuntime(809):  at android.os.AsyncTask$3.done(AsyncTask.java:299)
01-02 14:32:13.828: E/AndroidRuntime(809):  at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
01-02 14:32:13.828: E/AndroidRuntime(809):  at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
01-02 14:32:13.828: E/AndroidRuntime(809):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
01-02 14:32:13.828: E/AndroidRuntime(809):  at java.util.concurrent.FutureTask.run(FutureTask.java:137)
01-02 14:32:13.828: E/AndroidRuntime(809):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
01-02 14:32:13.828: E/AndroidRuntime(809):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
01-02 14:32:13.828: E/AndroidRuntime(809):  at java.lang.Thread.run(Thread.java:856)
01-02 14:32:13.828: E/AndroidRuntime(809): Caused by: java.lang.IllegalArgumentException: Cannot bind argument at index 2 because the index is out of range.  The statement has 0 parameters.
01-02 14:32:13.828: E/AndroidRuntime(809):  at android.database.sqlite.SQLiteProgram.bind(SQLiteProgram.java:212)
01-02 14:32:13.828: E/AndroidRuntime(809):  at android.database.sqlite.SQLiteProgram.bindString(SQLiteProgram.java:166)
01-02 14:32:13.828: E/AndroidRuntime(809):  at android.database.sqlite.SQLiteProgram.bindAllArgsAsStrings(SQLiteProgram.java:200)
01-02 14:32:13.828: E/AndroidRuntime(809):  at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:47)
01-02 14:32:13.828: E/AndroidRuntime(809):  at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1314)
01-02 14:32:13.828: E/AndroidRuntime(809):  at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1253)
01-02 14:32:13.828: E/AndroidRuntime(809):  at com.examples.android.calendar.DatabaseConnector.getdate(DatabaseConnector.java:87)
01-02 14:32:13.828: E/AndroidRuntime(809):  at com.examples.android.calendar.DayPlan$GetContacts.doInBackground(DayPlan.java:70)
01-02 14:32:13.828: E/AndroidRuntime(809):  at com.examples.android.calendar.DayPlan$GetContacts.doInBackground(DayPlan.java:1)
01-02 14:32:13.828: E/AndroidRuntime(809):  at android.os.AsyncTask$2.call(AsyncTask.java:287)
01-02 14:32:13.828: E/AndroidRuntime(809):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
01-02 14:32:13.828: E/AndroidRuntime(809):  ... 4 more

How can I display my events with 2012-12-30 date only?

  • 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-16T19:37:58+00:00Added an answer on June 16, 2026 at 7:37 pm

    rawQuery is to use only with very particular queries, and only if you can’t do otherwise.

    Your query is rather simple, and should be expressed this way :

    return database.query("calendar_events", new String[] {"_id", "event"}, 
                 "date = ?", new String[] { data }, null, null, "date");
    

    Parameters are:

    1. Table name
    2. projection (the columns you want). _id is very important as CursorAdapters use it to find their way in your data. event is the column you are interested in
    3. where clause. that’s your query. ? are replaced with args
    4. whereArgs. used to replace your ?. Note that escaping and quotes are handled by sqlite entirely.
    5. group by
    6. having
    7. order by
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using hibernate and i want to display only those records of table
I have a table for which I want to display only the first row
Below is my code snippet , I want to display only 10 records from
I want display data from database in Listbox...Here is my code, It is not
Suppose there is a frame with some image.I want to display only those parts
I want to display a lot of data in DataGridView (more than 1000 rows
I want to display only children categories of a particular category. Suppose I have
I have two tables and I want to display only the child ID that
I want to display Hello World with calibri.ttf using only AC3. How would I
I have a partial that I want to display in a layout only when

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.