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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:15:03+00:00 2026-05-28T05:15:03+00:00

Found more than 10 tutorials to cursors but I can’t understand that. My question

  • 0

Found more than 10 tutorials to “cursors” but I can’t understand that.
My question is: How can I read data from a database?

For example:
Database name: Test_Database
Table name: tbl_users
In it are two columns: id, user_name

Now I like to read the user_name with id 3
==> SELECT user_name FROM tbl_useres WHERE id = 3

How can I give that out to a TextView, Toast or Alert?

  • 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-28T05:15:04+00:00Added an answer on May 28, 2026 at 5:15 am

    The best way to achieve this (at least my opinion ) is to create your custom SqliteDatabaseHelper and you can create a function like this :

    public Cursor executeSQLQuery(String query){
        Cursor c = sqliteDb.rawQuery(query,null); // private static  SQLiteDatabase sqliteDb; 
        return c;
    }
    

    which returns Cursor and after that you can use this cursor like :

    CustomDatabaseHelper dbHelper = new CustomDatabaseHelper(params...);
    String sql = "SELECT name FROM cards WHERE id=2";
    Cursor cursor = dbHelper.executeSQLQuery(sql);
    if(cursor.getCount()==0){
      // do something when you don't have any data, show message or something like this
    } else if(cursor.getCount()>0){
        for(cursor.move(0); cursor.moveToNext(); cursor.isAfterLast()){
           String getName = cursor.getString(cursor.getColumnIndex("name"));
        }
    }
    

    This is at least how I’m using Cursor to get data from Database.

    Hope it helps.

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

Sidebar

Related Questions

So this is IT more than programming but Google found nothing, and you guys
Unfortunately, the problem is not more specific than that. I've found a few examples
I found a posting on the MySQL forums from 2005 , but nothing more
I found this question but it was only similar and, more importantly, dated by
I've found a similar question here , but I'm looking for more general solutions.
I am just beginning Haskell, but from all the online tutorials I've found I
The tutorials I've found on WxPython all use examples from Linux, but there seem
I have found C++ FQA Lite very edificatory and would like to read more
When moving to Spring 2.5.x I found that it adds more stereotype annotations (on
Question Where can I find really good, thorough and comprehensive Android development instruction that

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.