Skip to main content
se añadieron 307 caracteres en el cuerpo
Origen Enlace
    public final static String TABLE_DASHBOARD = "dashboard";
    public final static String ID_DASHBOARD = "idDashboard";
    public final static String MAIN_DASHBOARD = "mainDashboard";
    public final static String TITLE = "title";
    public final static String DESCRIPTION = "description";

    public final static String CREATE_TABLE_DASHBOARD = "CREATE TABLE " + TABLE_DASHBOARD + " ("
            + ID_DASHBOARD + " INTEGER PRIMARY KEY AUTOINCREMENT, "
            + TITLE + " VARCHAR(50) UNIQUE, "
            + DESCRIPTION + " VARCHAR(255), "
            + MAIN_DASHBOARD + " TINYINT(1) DEFAULT 0 "
            + ")";
    public final static String CREATE_TABLE_DASHBOARD = "CREATE TABLE " + TABLE_DASHBOARD + " ("
            + ID_DASHBOARD + " INTEGER PRIMARY KEY AUTOINCREMENT, "
            + TITLE + " VARCHAR(50) UNIQUE, "
            + DESCRIPTION + " VARCHAR(255), "
            + MAIN_DASHBOARD + " TINYINT(1) DEFAULT 0 "
            + ")";
    public final static String TABLE_DASHBOARD = "dashboard";
    public final static String ID_DASHBOARD = "idDashboard";
    public final static String MAIN_DASHBOARD = "mainDashboard";
    public final static String TITLE = "title";
    public final static String DESCRIPTION = "description";

    public final static String CREATE_TABLE_DASHBOARD = "CREATE TABLE " + TABLE_DASHBOARD + " ("
            + ID_DASHBOARD + " INTEGER PRIMARY KEY AUTOINCREMENT, "
            + TITLE + " VARCHAR(50) UNIQUE, "
            + DESCRIPTION + " VARCHAR(255), "
            + MAIN_DASHBOARD + " TINYINT(1) DEFAULT 0 "
            + ")";
Origen Enlace

Al desinstalar mi aplicacion de android no se eliminan la informacion de la base de datos (SQLite)

Durante el desarrollo de la app, instale la aplicación en un dispositivo con android 9. Posteriormente, en la base de datos tuve que agregar una tabla nueva y por lo tanto desinstale la app para que al ejecutar se vieran los cambios. Pero sucede que al reinstalar no se agrega la nueva tabla y un campo de una tabla se esta manteniendo en la base de datos.

Esta es mi clase de configuracion de mi bd

public class DBCreator extends SQLiteOpenHelper {

    private final static int VERSION = 1;
    private final static String NAME = "kanban";
    private static DBCreator instance;

    public static void createInstance(Context context) {
        if (instance == null) {
            instance = new DBCreator(context);
        }
    }

    public static DBCreator getInstance() {
        return instance;
    }

    private DBCreator(@Nullable Context context) {
        super(context, NAME, null, VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(DBQuery.CREATE_TABLE_DASHBOARD);
        db.execSQL(DBQuery.CREATE_TABLE_CATEGORY);
        db.execSQL(DBQuery.CREATE_TABLE_TASK);
        db.execSQL(DBQuery.CREATE_TABLE_IMAGE);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}

El error que me sale es:

android.database.sqlite.SQLiteException: no such table: dashboard (code 1 SQLITE_ERROR): , while compiling: SELECT * FROM dashboard ORDER BY mainDashboard DESC

La tabla que "no he creado" es

    public final static String CREATE_TABLE_DASHBOARD = "CREATE TABLE " + TABLE_DASHBOARD + " ("
            + ID_DASHBOARD + " INTEGER PRIMARY KEY AUTOINCREMENT, "
            + TITLE + " VARCHAR(50) UNIQUE, "
            + DESCRIPTION + " VARCHAR(255), "
            + MAIN_DASHBOARD + " TINYINT(1) DEFAULT 0 "
            + ")";