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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:24:21+00:00 2026-05-24T00:24:21+00:00

I have a problem with SQLite, it doesn’t work when i call DataBaseHelper(who store

  • 0

I have a problem with SQLite, it doesn’t work when i call DataBaseHelper(who store the onCreate and onUpgrade method), even if the version of DataBase change, and i have no errors.

For resuming my application, my main activity call the Singleton, who execute DataBaseHelper.

My main Activity :

public class irdesApplication extends Activity {

public static final String LOG_TAG="Droidnova";
private Context context = this;
CheckUpdate chUp;
ProgressBar bar;
TextView txtLoading;
Data d = new Data();
Singleton s;

public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.page_loading);
    bar = (ProgressBar) findViewById(R.id.ProgressBarLoad);
    txtLoading = (TextView) findViewById(R.id.txtLoading);
    new Thread(myThread).start();
    bar.setProgress(0);

    //Initialisation de la Base
    s.getInstance(context);

    // ---------- Constitution des logs  ------------ //

    int logParam =0;
    Log.v(LOG_TAG, "logParam value" + logParam);
    [...]

}

}

My Singleton :

package com.irdes.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

public class Singleton {

private static Singleton instance;
private DataBaseHelper baseIrdes;
private SQLiteDatabase db;
private Data d = new Data();

private Singleton(Context context){
    System.out.println("Construction du Singleton");
    d.loadPercent = 10;
    d.loadTxt = "Initialisation";
    baseIrdes = new DataBaseHelper(context, d.dbName, null, d.dbVersion);
}

public static synchronized Singleton getInstance(Context context){
        if (instance == null)
        instance = new Singleton(context);
        return instance;
}

public void setValue(SQLiteDatabase value){
    db = value;
}
public SQLiteDatabase getValue(){
    return db;
}

protected void open(){
    //on ouvre la BDD en écriture
    db = baseIrdes.getWritableDatabase();
}

protected void close(){
    //on ferme l'accès à la BDD
    db.close();
}

}

My DataBasHelper Activity :

public class DataBaseHelper extends SQLiteOpenHelper {

private Data d = new Data();

public DataBaseHelper(Context context, String name, CursorFactory factory, int version) {
    super(context, name, factory, version);
    System.out.println("Test");
    // TODO Auto-generated constructor stub
}

@Override
public void onCreate(SQLiteDatabase db) {

    d.updateDataBase = true;
    //Activation prise en charge Foreign Keys
    db.execSQL("PRAGMA foreign_keys = ON;");

    [...]
    db.execSQL("CREATE TABLE "+d.actualiteTable+" ("+d.colActualiteNum+ " INTEGER PRIMARY KEY , "+
            d.colActualiteTitre+ " TEXT, "+d.colActualiteDate+" TEXT, "+d.colActualiteLien+" TEXT, "+d.colActualiteTypeActu+" INTEGER, " +
                    "FOREIGN KEY ("+d.colActualiteTypeActu+") REFERENCES "+d.typeActuTable+" ("+d.colTypeActuNum+"))");
    [...]
      System.out.println("Create table Complete");
      InsertRows(db);
}



@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    [...]
    db.execSQL("DROP TABLE IF EXISTS "+d.actualiteTable);
    [...]

    onCreate(db);

}

public void InsertRows (SQLiteDatabase bdd){

    System.out.println("Chargement des données");

    bdd = this.getWritableDatabase();
    ContentValues cv=new ContentValues();

    // --------- TypeActu -------- //

    cv.put(d.colTypeActuNum, 1);
    cv.put(d.coltypeActuLibelle, "Gen");
    bdd.insert(d.typeActuTable, d.colTypeActuNum, cv);
    [...]
    bdd.close();
    System.out.println("Données inserées");

}

And Data class for more comprehension :

public static final String dbName="irdesDB";
public static final int dbVersion=46;

public static final String actualiteTable="Actualite";
public static final String colActualiteNum="numActu";
public static final String colActualiteTitre="titre";
public static final String colActualiteDate="date";
public static final String colActualiteLien="lien";
public static final String colActualiteTypeActu="numTypeActu";
[...]

I have aslo posted in a french forum here, if it could help: http://www.developpez.net/forums/d1110144/java/general-java/java-mobiles/android/sqlite-onupgrade-ne-s-execute-plus/#post6141983

What’s the problem ? I don’t understand why onCreate and onUpgrade doesn’t executed.

  • 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-05-24T00:24:21+00:00Added an answer on May 24, 2026 at 12:24 am

    Those methods are only called when you call getWritableDatabase() or getReadableDatabase().

    In your case, invoke the baseIrdes.open() method.

    The same problem was address here.

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

Sidebar

Related Questions

I have problem with return statment >.< I want to store all magazine names
So, I have an odd problem. I'm working with an SQLite database through javascript
I have a problem in JDBC driver for SQLite. I am executing a query
I have a problem with the init() method of a standard NSObject. I wrote
I have a SQLite DB that I'm using to store app data, and I
Here's the problem, I have a unicode string as input to a python sqlite
I have a listview that is sourced by an sqlite db. I call fillData()
i have a problem that i can't solve ! (sqlite3, but i think it
I have problem in some JavaScript that I am writing where the Switch statement
I have problem with starting processes in impersonated context in ASP.NET 2.0. I am

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.