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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:31:59+00:00 2026-06-13T15:31:59+00:00

I have this class, that gets the data from the database and shows in

  • 0

I have this class, that gets the data from the database and shows in a listview.

Is there a way to get the Id from the database and toast it?

Now the toast is returning: android.database.sqlite.SQLiteCursor@4180c088

 public class AndroidSQLite extends Activity { 

 private SQLiteAdapter
 mySQLiteAdapter;

 @Override
 public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
     setContentView(R.layout.main);
     ListView listContent = (ListView)findViewById(R.id.contentlist);

     mySQLiteAdapter = new SQLiteAdapter(this);
     mySQLiteAdapter.openToRead();

     Cursor cursor = mySQLiteAdapter.queueAll();
     startManagingCursor(cursor);

     String[] from = new String[]{SQLiteAdapter.KEY_NOME,SQLiteAdapter.KEY_ID};
     int[] to = new int[]{R.id.text,R.id.id};

     SimpleCursorAdapter cursorAdapter =
      new SimpleCursorAdapter(this, R.layout.row, cursor, from, to);

     listContent.setAdapter(cursorAdapter);

     listContent.setOnItemClickListener(new OnItemClickListener() {
         public void onItemClick(AdapterView<?> parent, View view, int position,
                 long id) {
                //GET ID FROM DATABASE
                Toast.makeText(getBaseContext(), parent.getItemAtPosition(position).toString(), Toast.LENGTH_LONG).show();
                //THIS TOAST IS RETURNING "android.database.sqlite.SQLiteCursor@4180c088"
         }
     });

     mySQLiteAdapter.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-13T15:32:01+00:00Added an answer on June 13, 2026 at 3:32 pm

    Simply use the id parameter of onItemClick():

    Toast.makeText(getBaseContext(), id + "", Toast.LENGTH_LONG).show();
    

    For future reference you are currently trying to use an entire Cursor as a String, you want to select a column like this:

    Toast.makeText(getBaseContext(), parent.getItemAtPosition(position).getLong(0), Toast.LENGTH_LONG).show();
    

    (For a SimpleCursorAdapter the first column is always the _id column, hence getLong(0).)

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

Sidebar

Related Questions

I currently have a function that gets some data from the database and puts
I have a standalone Java application that gets data from a database and displays
I have this class that contains vars for db connection; Imports Microsoft.VisualBasic Imports System.Data.SqlClient
I have a class that gets arranged into a hierarchy, such as this: class
I have this PHP function that gets the data of the currently logged in
I have this class that have a function to load other classes and create
I have this class that has many class members, and a lot of different
I have this c# class that calculates n choose k and then generates all
I have this class called PollFrame that extends JFrame in a file called PollFrame.java
I have class that looks like this: class A { public: class variables_map vm

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.