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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:20:04+00:00 2026-06-13T10:20:04+00:00

I created database table in my android app. I used this query: CREATE TABLE

  • 0

I created database table in my android app. I used this query:

CREATE TABLE foo (_id INTEGER PRIMARY KEY AUTOINCREMENT, mybool BOOLEAN)

Than I added row to the table, that the value of mybool will be true.
I ran the sqlite3 command to see the value in the table, and I saw:

  _id    |    mybool
----------------------
   1     |      1

That is corret, the true value became to 1.

The strange thing is in the reading. I read the table like that:

ContentValues values = new ContentValues();
Cursor cursor = db.rawQuery("SELECT * FROM foo", null);
DatabaseUtils.cursorRowToContentValues(cursor, values);

Then I get strange result:

values.getAsBoolean("mybool"); // return false - WRONG
values.getAsInteger("mybool"); // return 1 = true - CORRECT

I use the code like that to get boolean value:

values.getAsInteger("mybool") != 0; 

But it’s strange.

Why I get always false in the getAsBoolean function? Is there any bug in the ContentValues class? Anyone else having this problem?

  • 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-13T10:20:05+00:00Added an answer on June 13, 2026 at 10:20 am

    getAsBoolean does not return a boolean but a Boolean wrapper object, which can be either null, Boolean.FALSE, or Boolean.TRUE.
    If you can ensure that there aren’t NULLs, use values.getAsBoolean("mybool").booleanValue() to get the actual value.

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

Sidebar

Related Questions

I created one app for database which contains a student table and 3 fields
I have created a table on an Oracle 10g database with this structure :
I am using AdventureWorks2012 database. I created the following index on Sales.SalesOrderHeader table create
this is my code to create database table String sqlQueryToCreateFileTable = create table if
Exception: CREATE TABLE android_metadata failed Failed to setLocale() when constructing, closing the database android.database.sqlite.SQLiteException:
In my android app I've got the below code creating my database. This works
I have some simple code which should create a database. package com.webfoo.android.databaseExample; import android.app.Activity;
I had created database in my android app, then inserted a statement. Everything worked,
I have an Android application that uses the Android database to create tables and
I recently created my simple log4net database table for logging via the adonet appender..

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.