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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:11:55+00:00 2026-05-25T00:11:55+00:00

I have a description column in my SQLite database that contains some text to

  • 0

I have a description column in my SQLite database that contains some text to display when taping to every marker. Every marker has its own description. The problem is when I tap on one marker, I’m getting all of the other AlertDialogs displayed. I’m using the following code:

@Override
protected boolean onTap(int index) {
     db = openHelper.getWritableDatabase();

     String[] result_columns = new String[] {COL_DESCRI};
     Cursor cur = db.query(true, TABLE_COORD, result_columns, null, null, null, null, null, null);
     cur.moveToFirst();
     while (cur.isAfterLast() == false) {
          String description = cur.getString(cur.getColumnIndexOrThrow("description"));
          AlertDialog.Builder dialog = new AlertDialog.Builder(Geo.this);
          dialog.setTitle("Infos.");
          dialog.setMessage(description);
          dialog.setPositiveButton("OK", new OnClickListener() {    
               @Override
               public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
               }
           });
           dialog.show();

           cur.moveToNext();
    }
    cur.close();
    db.close();

    return true;
}

The onTap function seems to be working:

protected boolean onTap(int index) {
     db = openHelper.getWritableDatabase();

     String[] result_columns = new String[] {COL_DESCRI};
     Cursor cur = db.query(true, TABLE_COORD, result_columns, null, null, null, null, null, null);

     cur.moveToPosition(index);
     String description = cur.getString(cur.getColumnIndexOrThrow("description"));

     AlertDialog.Builder dialog = new AlertDialog.Builder(Geo.this);
     dialog.setTitle("Infos.");
     dialog.setMessage(description);
     dialog.setPositiveButton("OK", new OnClickListener() {    
          @Override
          public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
          }
     });
     dialog.show();
     cur.close();

     db.close();

             return true;
        }

I am aware that I have to assign an index to every AlertDialog, but I don’t know how to do it. I’ve tried to solve this but I can’t seem to do it. Any suggestions on how to solve the problem?

  • 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-25T00:11:55+00:00Added an answer on May 25, 2026 at 12:11 am

    You appear to be looping through all the items in your results.

    cur.moveToFirst() moves you to the first item, then cur.moveToNext(); moves you to the next item on each iteration. You are then displaying the alert dialog for every item!

    You really shouldn’t need to load the data like this every time the user clicks on an item, but the simplest [not recommended] way to fix your code would be to use cur.moveToPosition(index) instead of your loop.

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

Sidebar

Related Questions

I have a table [Book] in a database that has a [AuthorId] and [Description]
I have a table with a column named Description that contains XML like: <Parent>
I have a model that has one column right now, description , that populates
I have some columns in my table, descriptions column contains some information like; a1b01,Value
I have a table in the database where a Description column is of nvarchar(MAX)
I have a column with name data-description which has entries like Mumbai,Maharastra,India London,London, Britain
I have an SQLite Database with 5000 rows that is loaded into a tableview.
I have an SQLite database with 4 tables in it that I want to
I have a table that contains a nvarchar column that allows nulls. I have
I have a database that I want to add a column to, I changed

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.