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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:32:34+00:00 2026-06-17T04:32:34+00:00

If I make any change to database like adding new column in my android

  • 0

If I make any change to database like adding new column in my android application.
and If I have already installed that on my phone.
when I reinstall / update that application on mobile it doesn’t update the database changes.

My database code is :

package com.screenmagic.smsmagicmobileapp;

import java.text.SimpleDateFormat;
import java.util.Date;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;


public class DatabaseHandler extends SQLiteOpenHelper {


private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "Test";


public DatabaseHandler(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
    Log.d(TAG, "onCreate OF DatabaseHandler");

    db.execSQL("DROP TABLE IF EXISTS history");
    String CREATE_SMS_HISTORY_TABLE = "CREATE TABLE  history("+
    "id INTEGER PRIMARY KEY AUTOINCREMENT, mobileNumber TEXT, smsText TEXT)";
    Log.d("Insert: ", "Table create query:: "+ CREATE_SMS_HISTORY_TABLE);
    db.execSQL(CREATE_SMS_HISTORY_TABLE);
    Log.d("Insert: ", "Table created ..");

}

// Upgrading database
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    db.execSQL("DROP TABLE IF EXISTS sms_history");
    onCreate(db);
}


}
  • 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-17T04:32:35+00:00Added an answer on June 17, 2026 at 4:32 am

    Just use the onUpgrade (as an override) method, and you can put your database upgrades there. this way, none of the existing data will be blown away when the application has already been installed.

    And make sure you don’t drop the table as you’re currently doing on:

    db.execSQL("DROP TABLE IF EXISTS sms_history");
    

    See reference for the method here and a video on how to implement it here

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

Sidebar

Related Questions

Is there any way to make this work in Java? public static void change(List<?
How do I make any wxPython widget (like wx.Panel or wx.Button) automatically expand to
Does something like this make any sense at all in Java? class A<T extends
Does it make any sense to include a captcha when registration already requires email
http://oeis.org/A005773 I looked into that page but most of the abbreviations didn't make any
I have an array called $users (below), that i would like to print first_name
I am creating a C# application using Visual Studio that uses an SQLExpress database.
Our client has an application that stores blobs in database which has now grown
I'm writing an application that is using a database (currently MySQL 4) to store
can anyone help, we have a sql server 2005 database installed (actually its an

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.