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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:47:21+00:00 2026-06-15T17:47:21+00:00

I got a sqlite database and i wanted to retrieve a specific column of

  • 0

I got a sqlite database and i wanted to retrieve a specific column of data and store it into a string array. Inside the database there are two columns. There will be multiple row of data with the same username and I wanted to retrieve the user’s “ContentPath” and store it into a string array. But I don’t know how to retrieve that specific column data…

    public String[] get_contentByEmailID(String emailid){
    String[] returnMsg = null;
    helper = this.getReadableDatabase();

    Cursor c = helper.rawQuery("SELECT tableid, emailid, contentpath" +
            " from w_content where emailid='"+emailid"' ", null);



    int contentpathColumn = c.getColumnIndex("contentpath");


    if (c.moveToFirst()) {
        do {
            returnMsg = new String[2]; 

            String contentpath = c.getString(contentpathColumn);

            returnMsg[0] = emailid_sync;

            returnMsg[1] = contentpath;


        } while (c.moveToNext());
    }
    if (c != null && !c.isClosed()) {
        c.close();
    }
    if (helper!=null){
        helper.close();
    };
    return returnMsg;
}

When I called this function to retrieve the data. It comes up with emailid and contentpath.

String values[] = helper.get_contentByEmailID(SettingConstant.EMAIL);

Any comments will be appreciated.

  • 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-15T17:47:22+00:00Added an answer on June 15, 2026 at 5:47 pm

    The reason you got array filled with emailid and contentpath is, because you always reset the returnMsg on each row and fill it with such value. Since there will be varying row count, it is generally suggested that you use ArrayList, instead of building static length array.

    To fix it, change:

    String[] returnMsg = null;
    

    to:

    ArrayList<String> returnMsg = new ArrayList<String>();
    

    And then, in your do{}, do something like this:

    do {
        String contentpath = c.getString(contentpathColumn);
        returnMsg.add(contentpath);
    } while (c.moveToNext());
    

    Finally, change your return statement to:

    return returnMsg.toArray();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use an SQLite database to store some data for my app.
In my project I need to store an image into a sqlite database and
I've got an library which must read data from sqlite database by calling extern
I want to store an image(from url) into a sqlite database. For that I
We've got an app with Core Data and the backing store is a SQLite
I started by trying to store strings in sqlite using python, and got the
I've got a SQLite database and a table that uses an autoincrementing int as
I've got a SQLite database. I'd like to create a field and declare it
I'm using a SQLite database to store information on players and their teams using
SQLFiddle Link I've got an SQLite database with a bunch of test/exam questions. Each

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.