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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:15:28+00:00 2026-06-01T22:15:28+00:00

I am using a database to store date and want a single column returned

  • 0

I am using a database to store date and want a single column returned based on which id is given in the where claus.

    public String getPmax(String serial) {

    String[] columns = new String[]{KEY_SERIAL, KEY_PMAX};      
    Cursor c = ourDatabase.query(DATABASE_TABLE, columns, "serial = " + serial,
    null, null, null, null);

    String result = "nothing found";

    if(c != null) {

        int iPmax = c.getColumnIndex(KEY_PMAX); 

        c.moveToFirst();
        result = c.getString(iPmax);

    }

    return result;  

}

This code works if I use a serial that is in the database but it gives me a force close when i am using a serial that’s not in the database!

it says:

04-11 16:31:19.423: E/AndroidRuntime(21226): java.lang.RuntimeException: Unable to start activity ComponentInfo{nl.janjanus.solardetect/nl.janjanus.solardetect.DatabaseView}: android.database.sqlite.SQLiteException: no such column: g: , while compiling: SELECT serial, pmax FROM SolareCel WHERE serial = g

So my question is: How do I check if there is result? or do I need to check if the serial given is a serial that is in the database?

  • 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-01T22:15:30+00:00Added an answer on June 1, 2026 at 10:15 pm
        if (!(mCursor.moveToFirst()) || mCursor.getCount() ==0){
         //cursor is empty
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a database in my Java project and I want to store date
I am using SQLITE database and I store the date as a String. Now
I am re-using ListPreference for a setting which I store only in the database.
I have a BirthDate column in MySQL database table to store user's date of
I'm using time() to store date in the database. I have some kind of
I am using Microsoft Access database for storing data. In that, I stored date
I am using an sqlite database to store log data. My table has a
I'm using a MySQL database to store scores for my game. A very simplified
I have to store long strings in MySQL database using spring roo. I assumed
How to create reasonable expression to store password in database using Doctrine and Zend_Auth::setCredentialTreatment()

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.