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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:58:13+00:00 2026-06-14T12:58:13+00:00

I am trying to get the first column like below sql but my code

  • 0

I am trying to get the first column like below sql but my code show error.

SELECT subject FROM setting WHERE rowid=1

    public void getSetting(){
    result = "";

SQLiteDatabase db = myDbHelper.getReadableDatabase();   

Cursor c = db.query(true, "setting", new String[] {"subject", "language", "selection"}, "row=1", null, null, null, null, null);

    for(c.moveToFirst();!(c.isAfterLast());c.moveToNext()){

result = result + c.getString(0);
result = result + c.getString(0);
    result = result + c.getString(0);
    }
    if (c.getCount() == 0)              
    result = result + "result not found";   

c.close();      
db.close();         
myDbHelper.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-14T12:58:14+00:00Added an answer on June 14, 2026 at 12:58 pm

    Your stuff is a little hard to understand, but i think i have an idea what you want. You what to get a cursor to return only one row where the row’s id is a specific value. And you only want the string from one column of that returned row. I assume that the primary issue is your designation of the _id column that you’re looking for. You either called it row or rowid, you gotta double-check that.

    Moreover, i hope the following re-write clears up further issues that you might have.

    public String getSetting() {
        String result = "";
        String[] columns = {"subject"}; 
        String[] selectionArgs = {"1"};
        String LIMIT = String.valueOf(1); // <-- number of results we want/expect
    
        SQLiteDatabase db = myDbHelper.getReadableDatabase();   
        Cursor c = db.query(true, "setting", columns, "rowid = ?", selectionArgs, null, null, null, LIMIT);     
    
        if (c.moveToFirst()) {
            result = result + c.getString(0);
        } else {
            result = result + "result not found";
        }
    
        c.close();      
        myDbHelper.close();
        return result;
    }    
    

    Moreover, moreover. If you get an error you should post it so that we have an idea what’s going on.

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

Sidebar

Related Questions

I'm trying to get data from file. The file first has three lines of
I am trying get the data from my database but i am not getting
I'm working with Entity Framework code first. The error occurs when trying to save
I'm trying to get the first paragraph height within a div and store it
I am trying to get the first word in the line that matches the
I am trying to get my first button to update a display number in
Ok I am trying to get the users First Name the form gets their
When trying to get geolocation on iPhone the first time - I declined. Every
I am trying to get the timestamp of the first day of the month
I am trying to get the names of all first level directories under given

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.