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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:23:55+00:00 2026-06-03T21:23:55+00:00

I can’t upgrade my android database: public class database extends SQLiteOpenHelper { // Database

  • 0

I can’t upgrade my android database:

public class database extends SQLiteOpenHelper {

// Database creation sql statement
private static final String DATABASE_NAME = "myDatabase";
private static final String DATABASE_CREATE_login = "CREATE TABLE login (userJoomla INTEGER, idUSER INTEGER PRIMARY KEY, name varchar(20), email varchar(50))";
private static final String DATABASE_CREATE_position = "CREATE TABLE position(latitude VARCHAR(20), longitude VARCHAR(20), address VARCHAR(100), lastUpdate DATETIME)";
private static final String DATABASE_CREATE_favorites = "CREATE TABLE favorites(_id INTEGER PRIMARY KEY AUTOINCREMENT, idSPB INTEGER UNIQUE NOT NULL)";
private static final int DATABASE_VERSION = 2;


public database(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
}

@Override
public void onCreate(SQLiteDatabase db) {
    // Create the table
    db.execSQL(DATABASE_CREATE_login);      
    db.execSQL(DATABASE_CREATE_position);   
    db.execSQL(DATABASE_CREATE_favorites);  

}


// Method is called during an upgrade of the database, e.g. if you increase
// the database version
@Override
public void onUpgrade(SQLiteDatabase database, int oldVersion,int newVersion) {
    Log.w(database.class.getName(),"Upgrading database from version " + oldVersion + " to " + newVersion + ", which will destroy all old data");
    database.execSQL("DROP TABLE IF EXISTS " + DATABASE_NAME);
    onCreate(database);
}

}

The exception I caught was:

 Can't upgrade read-only database from version 1 to 2:

I read here that it should be solved with;

    db = fav.getWritableDatabase();

But now I have this mistake:

table login already exists.

What should I do?

Thank you in advance

  • 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-03T21:23:57+00:00Added an answer on June 3, 2026 at 9:23 pm

    You are doing database.execSQL("DROP TABLE IF EXISTS " + DATABASE_NAME);, i.e.:

    DROP TABLE IF EXISTS myDatabase
    

    Change it to the correct table name instead.

    DROP TABLE IF EXISTS login
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can we use the asterisk character * for a search action in SQL database?
Can I register a .Net COM class with the SingleUse -flag? The reason I
can anyone tell me why this doesn't work? db = openOrCreateDatabase(database.db, SQLiteDatabase.CREATE_IF_NECESSARY, null); db.setLocale(Locale.getDefault());
Can't work out a way to make an array of buttons in android. This
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
Can we close all known/unknown connections to database with the code? I'm using Access
Can we write all the control events in a seperate class file in different
Can you use an object's existence as the condition of an if statement in
can anyone help me in trying to check whether JavaScript is enabled in client
Can 2 or more equations defining a function in Haskell share the same where

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.