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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:27:20+00:00 2026-06-18T11:27:20+00:00

I am working on sqlite in my android app. I am doing db.getVersion() to

  • 0

I am working on sqlite in my android app.

I am doing db.getVersion() to get current version of my database.

it is showing 3 in logcat.

even in constructor i set 4 as a version number.

public Helper(Context context)
    {
        super(context, DATABASE_NAME, null,4);
    }

i am giving 4 it should take 4 as version number.

but its not behaving like this. it is showing 3 as version number.

please any suggestion.

UPDATE:-

    public class Helper extends SQLiteOpenHelper {
        public static final String  DATABASE_NAME = "helper.db";

        public static final String TITLE = "title";
        public static final String AUTHOR = "author";
        public static final String ISBN = "isbn";

        public Helper(Context context)
        {
            super(context, DATABASE_NAME, null,4);
        }

        @Override
        public void onCreate(SQLiteDatabase db) {

                db.execSQL( "CREATE TABLE book1(_id INTEGER PRIMARY KEY AUTOINCREMENT,title TEXT, author TEXT,isbn INTEGER);");
                Log.v("Create Table", "CREATE TABLE book1(_id INTEGER PRIMARY KEY AUTOINCREMENT,title TEXT, author TEXT,isbn INTEGER);");

Log.v("version ", "Version number is "+db.getVersion());

}
  • 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-18T11:27:22+00:00Added an answer on June 18, 2026 at 11:27 am

    You are checking the version number in the onCreate function, why? the OnCreate function should only be called the first time the datbase is created from scratch, in this case it should build the DB as you require fitting to the version you are using.

    Can you try checking the DB version after the DB has been created and you ask to get a readable or writable instance of it?

    SQLiteDatabase db = new Helper(context).getWritableDatabase();
    db.getVersion(); // what value do you get here?
    

    check out the source code of android 4.1.1 SQLiteOpenHelper, here it seems as the db version should be 0 inside the onCreate function, I guess it might be implemented in another way on the version you are testing on.
    http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.1.1_r1/android/database/sqlite/SQLiteOpenHelper.java#242

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

Sidebar

Related Questions

I'm working on my first android app and have an SQLite database set up
I am working on JUnit tests for my Android app which uses a SQLite
I'm working on my first SQLite database app and after two days of struggling,
I am working on android app and am trying to get fragments working but
i am working with sqlite database in Android for first time. i have create
I'm using ORMLite & SQLite as my database, and I'm working on a android
I'm working on an application which uses SQLite Database on Android.I have a custom
i am working on an android app which stores data in sqlite db i
I am currently working with android and sqlite database. I have attached the database
I am working with sqlite database.... app is working in 2.3 and later... when

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.