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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:53:04+00:00 2026-06-06T02:53:04+00:00

I have tried looking though several of the already asked question about this topic

  • 0

I have tried looking though several of the already asked question about this topic but I still can not get my file to work. I think maybe some direct direct help might be just what i need, so I humbly ask the community for help. Thank you for your time

public class RemindersDbAdapter {

//
// Database Related Constants
//
private static final String DATABASE_NAME = "data";
private static final String DATABASE_TABLE = "reminders";
private static final int DATABASE_VERSION = 3;

public static final String KEY_TITLE = "title";
public static final String KEY_CUSTOMER = "body";
public static final String KEY_DATE_TIME = "reminder_date_time";
public static final String KEY_END_TIME = "reminder_end_time";
public static final String KEY_ROWID = "_id";


private static final String TAG = "ReminderDbAdapter";
private DatabaseHelper mDbHelper;
private static SQLiteDatabase mDb;

/**
 * Database creation SQL statement
 */
private static final String DATABASE_CREATE =
        "create table " + DATABASE_TABLE + " ("
                + KEY_ROWID + " integer primary key autoincrement, "
                + KEY_TITLE + " text not null, " 
                + KEY_CUSTOMER + " text not null, " 
                + KEY_DATE_TIME + " text not null);" ;



private final Context mCtx;

private static class DatabaseHelper extends SQLiteOpenHelper 
{

    DatabaseHelper(Context context) 
    {

        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) 
    {
        db.execSQL(DATABASE_CREATE);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
    {
        Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
                + newVersion + ", which will destroy all old data");
        db.execSQL("DROP TABLE IF EXISTS " + DATABASE_TABLE);

        //Adding a Column 
     // If you need to add a column
        if (newVersion > oldVersion) 
        {
            //example I tried pulling from the internet
            db.execSQL(
                "ALTER TABLE foo ADD COLUMN new_column INTEGER DEFAULT 0");
        }

        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-06T02:53:06+00:00Added an answer on June 6, 2026 at 2:53 am

    If you want to upgrade your database simply add the new column in your CREATE statement, then increment the version.

    Your code tries to add a column to a table that you have just dropped…

    db.execSQL("DROP TABLE IF EXISTS " + DATABASE_TABLE); // Delete table
    ...
    db.execSQL("ALTER TABLE foo ADD COLUMN new_column INTEGER DEFAULT 0"); // Won't find the table 
    

    Simply change this:

    private static final String DATABASE_CREATE =
            "create table " + DATABASE_TABLE + " ("
                    + KEY_ROWID + " integer primary key autoincrement, "
                    + KEY_TITLE + " text not null, " 
                    + KEY_CUSTOMER + " text not null, " 
                    + KEY_DATE_TIME + " text not null, "
                    + "new_column INTEGER DEFAULT 0);" ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried searching over the internet about this problem but not able to
I have tried to answer this myself, by looking up several questions at StackOverflow.
i have tried looking online but had no luck, How i could delete all
Have tried to find solutions for this and can't really come up with anything.
I have read several threads about memory issues in R and I can't seem
I have been looking around for solutions, and tried to implement what is often
I have tried this: #define format(f, ...) \ int size = strlen(f) + (sizeof((int[]){__VA_ARGS__})/sizeof(int))
I have tried many permutations but they all don't seems to work well. Am
I have come across several solutions here and across the web but none seem
I am new to jQuery but have a question I hope some of you

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.