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

The Archive Base Latest Questions

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

This is a simple one! yet, I am missing something. Please help me out.

  • 0

This is a simple one! yet, I am missing something. Please help me out.
Here, I am trying to fetch values by id, but not able to do so. It is returning same values even after changing id’s value.

    db = openOrCreateDatabase("DBSOURCE", 0, null);
    Cursor cursorc = db.rawQuery("SELECT * FROM LIST WHERE ID="+id+"", null);
    cursorc.moveToFirst();

    int NameID = cursorc.getColumnIndex("Name");
    int mobilenumberID = cursorc.getColumnIndex("MoblieNumber");

    edName.setText(cursorc.getString(NameID));
    edMobNum.setText(cursorc.getString(mobilenumberID));

    cursorc.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-06T12:04:42+00:00Added an answer on June 6, 2026 at 12:04 pm

    1-
    or better to use parametrized statement

    String query = "SELECT COUNT(*) FROM " + tableName + " WHERE columnName = ?";
    cursor = db.rawQuery(query, new String[] {comment});
    

    2 – use if with conditon c.moveToFirst() or c.getCount() >0 or (!c.isAfterLast())

    if (c.moveToFirst()){ 
        do{ 
           //if you not need the loop you can remove that
           id = c.getInt(c.getColumnIndex("_id"));
       }
     while(cursor.moveToNext());
    }c.close(); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This one seems so simple, but I must be missing something... Given this SQL:
I know I'm missing something simple here, yet I can't figure it out. I
I suspect I'm missing something rather basic, yet I can't figure this one out.
This is probably a simple one to answer, but I'm stuck, so here goes.
This is probably a simple one but I can't seem to figure it out.
Probably simple question and I'm just missing something, but I'm stuck out of ideas.
This should be a simple one and I am dissapointed with myself but cant
This should be a simple one, but I'm a beginner with C#. Given a
Yet another Scrabble project question... This is a simple one. It seems I am
This question is not about timing something accurately on Windows (XP or better), but

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.