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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:02:40+00:00 2026-06-06T23:02:40+00:00

so I have two cursor that read data from database and write data to

  • 0

so I have two cursor that read data from database and write data to string, but cursors are always empty even if database have stored data. I checked with SQLite manager that database contain stored data.
Log Cat says that log named:”IF1″ and “IF2 are executed.
Here is my code, I hope someone could find what’s wrong..

String var;
final TextView t = (TextView) findViewById(R.id.textView2);
final TextView t2 = (TextView) findViewById(R.id.textView3);
Intent intent = getIntent();
var = intent.getStringExtra("datum");   

SQLiteDatabase db = openOrCreateDatabase ("MyDB", MODE_PRIVATE, null);

String q =" SELECT COALESCE (znak, '') as znak,COALESCE (sprava, '') as sprava, COALESCE(serija, '') as serija, COALESCE(podatak, '') as podatak, COALESCE(ponavljanja, '') as ponavljanja, vrijeme FROM tablica WHERE vrijeme LIKE '"+ var + "'" ;
Cursor c = db.rawQuery(q, null);      

String xy = "SELECT vrijeme FROM tablica WHERE vrijeme LIKE '"+ var + "'";
Cursor dd = db.rawQuery(xy, null);

if (dd.getCount() < 1) {
    Log.d("LIST.DETAILS", "IF1");
    dd.close();
    db.close();
    Toast.makeText(NapredakActivity.this, "Empty!", Toast.LENGTH_SHORT).show();
    startActivity(new Intent(this, calendar.class));
} else {
    String i = "";

    dd.moveToFirst();
    String st2 = dd.getString(dd.getColumnIndex("vrijeme"));
    i =  "Datum:" +"\t" + st2;
    t2.setText(i);
    dd.close(); 
}

if (c.getCount() < 1) {
    Log.d("LISTA.DETALJI", "IF2");
    c.close();
    db.close();
    Toast.makeText(NapredakActivity.this, "Empty!", Toast.LENGTH_SHORT).show();
    startActivity(new Intent(this, calendar.class));
} else {
    String j = "";

    c.moveToFirst();
    do {
        String cm55 = c.getString(c.getColumnIndex("sprava"));
        String cm = c.getString(c.getColumnIndex("serija"));
        String cm2 = c.getString(c.getColumnIndex("podatak"));
        String cm3 = c.getString(c.getColumnIndex("ponavljanja"));
        String cm_znak = c.getString(c.getColumnIndex("znak"));

        j = j +cm55+ "\n" + cm + "\t"  +cm2 +cm_znak + cm3 ;
    } while (c.moveToNext());

    t.setText(j);
    c.close();
    db.close();
}
  • 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-06T23:02:41+00:00Added an answer on June 6, 2026 at 11:02 pm

    I believe you are missing the wildcard characters from your WHERE clauses:

    "vrijeme LIKE '%"+ var + "%'"
    

    Otherwise:

    "vrijeme LIKE '"+ var + "'"
    

    Is the same as:

    "vrijeme = '"+ var + "'"
    

    Also I am guessing that English is not your first language, but your variable names are extremely cryptic. Consider using more descriptive names, it just helps the readability of your code.

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

Sidebar

Related Questions

I have data in two tables that I want to query from. Each table
I have two cursors in my procedure that only differ on the table name
In SQL Server, I have to use two cursor to iterate from two tables.
I'm using cursors to retrieve data from a database. I know how to retrieve
OK, so I have a cursor adapter that I cobbled together from various source
I have two classes (MVC view model) which inherits from one abstract base class.
I have two tables that need to be updated, Master and Identifiers: Master --MasterID
How can I show another cursor for multiple mice? I have two TMemos, two
I have a TableViewController that is using a grouped Style and has two(2) sections.
Here is what I want to implement: I have two hyperlinks that are displayed

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.