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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:04:06+00:00 2026-06-09T15:04:06+00:00

I have an activity and want to get data from my sqlite database. It

  • 0

I have an activity and want to get data from my sqlite database. It works, but my activity only retrieves the last row and not the whole column. What can i do to get the whole column?

This is the code in my database:

public String getName() {
String[] columns = new String[]{ KEY_ROWID, KEY_NAME };
Cursor c = db.query(NAME_TABLE, columns, null, null, null, null, null);
c.moveToFirst();
while(!c.isAfterLast()) {
String name = c.getString(c.getColumnIndex(KEY_NAME));
c.moveToNext();
}
c.close();
return name;
}

This is the code in my activities to contact the database:

Database getdata = new Database(this);
getdata.open();
String data = getdata.getName();
getdata.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-09T15:04:07+00:00Added an answer on June 9, 2026 at 3:04 pm

    See, As I said, Without seeing code I m helpless.. And after seeing your code..

    You are returning only single String from that function getName() instead it return String[].

    Note: this is only pseudo code.. Actual may be different..

    public String[] getName() {
    
            int i=0;
            String[] columns = new String[]{ KEY_ROWID, KEY_NAME };
            Cursor c = db.query(NAME_TABLE, columns, null, null, null, null, null);
            String name[] = new String[c.getCount()];
            c.moveToFirst();
              while(!c.isAfterLast()) {
                   name[i] = c.getString(c.getColumnIndex(KEY_NAME));
                   c.moveToNext();
                   i++;
              }
            c.close();
            return name;
    }
    

    And this one,

    Database getdata = new Database(this);
    getdata.open();
    String data[] = getdata.getName();
    getdata.close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I Have activity that get some data from the internet, and shows it to
I have an Activity that retrieves data from a web service. This data is
I want to send some data from activity A to activity B ONLY in
I want to fetch data from SQLITE database and display it in a LIST.
I want my android app to get data from an online database. Here are
I have this code by how I can get data from a sqllite database
I have a database in one activity that I want to open in another
I know how to pass data from one activity to another. But what I
I have three activities: Activity A - Displays a list of data from a
I want to sent the data from an Android device to PHP. I have

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.