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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:53:18+00:00 2026-05-26T17:53:18+00:00

I am trying to store a null value into the database but everytime I

  • 0

I am trying to store a null value into the database but everytime I load the value I get 0.

I declare the field just like “intVal integer"

This is how I retrieve it:

Integer x;

x = cursor.getInt(cursor.getColumnIndexOrThrow(MyDBAdapter.KEY_X));

Is that reliable? or is it undefined?

So it seems to me one cannot save null as an undefined integervalue

Many thanks

  • 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-26T17:53:19+00:00Added an answer on May 26, 2026 at 5:53 pm

    From the getInt() documentation:

    Returns the value of the requested column as an int.
    The result and whether this method throws an exception when the column value is null, the column type is not an integral type, or the integer value is outside the range [Integer.MIN_VALUE, Integer.MAX_VALUE] is implementation-defined.

    So, it’s an implementation detail which you shouldn’t rely on.

    You can still get the effect you want, though: you simply do the null check before you read the value.

    int index = cursor.getColumnIndexOrThrow(MyDBAdapter.KEY_X);
    Integer x = null;
    if (!cursor.isNull(index)
        x = cursor.getInt(index);
    
    // now x is either null or contains a valid value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to store an xml serialized object in a cookie, but i get
i am trying to store Chinese character in mysql database,but it store some messy
I am trying to input a date into an Oracle database. Sometime this value
I'm trying to store a password in a file that I'd like to retrieve
I am trying to store an xml value in my app.config file. The app.config
I'm trying to store a lightly filtered copy of a database for offline reference,
I am trying to store/retrieve a value that is stored in the Application Settings.
Hello iam trying to store sum information inside a SQL Server table , but
I'm trying to insert an HTML blob into our sql-server2005 database. I've been using
I'm trying to parse JSON string using Boost Spirit store JSON object into recursive

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.