Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] java – E/SQLiteLog: (1) table Estudiantes has no column named calificacion in android

Posted on November 11, 2022 By

Solution 1 :

It looks like that you added calificacion column later in the database.
I would do one of the following:

  1. Uninstalling and re-installing your app.
  2. The best and better approach is to drop and recreate Estudiantes table in onUpdate method, and increase the db version wheneveryou change the schema.

Problem :

This is the class that I´m using

public class DBHelper extends SQLiteOpenHelper {

    private static final String DB_FILE = "Database.db";
    private static final String TABLE = "Estudiantes";
    private static final String FIELD_ID = "id";
    private static final String FIELD_NAME = "nombre";
    private static final String FIELD_GRADE = "calificacion";

    public DBHelper(Context context){
        super(context, DB_FILE, null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String query = "CREATE TABLE " + TABLE + "(" +
                FIELD_ID + " INTEGER PRIMARY KEY, " +
                FIELD_NAME + " TEXT, " +
                FIELD_GRADE + " INTEGER);";
        db.execSQL(query);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        String query = "DROP TABLE IF EXISTS ?";
        String[] params = {TABLE};
        db.execSQL(query, params);
    }

    public void save(String nombre, int calificacion){
        SQLiteDatabase db = getWritableDatabase();
        ContentValues valores = new ContentValues();

        valores.put(FIELD_NAME, nombre);
        valores.put(FIELD_GRADE, calificacion);

        db.insert(TABLE, null, valores);
    }

    public int delete(String nombre){
        SQLiteDatabase db = getWritableDatabase();
        String clause = FIELD_NAME + " = ?";
        String[] args = {nombre};
        return db.delete(TABLE, clause, args);
    }

    public int find(String nombre){
        SQLiteDatabase db = getReadableDatabase();
        String filtrito = FIELD_NAME + " = ?";
        String[] args = {nombre};

        Cursor c = db.query(TABLE, null, filtrito, args, null, null, null);
        int result = -1;

        if(c.moveToFirst()) {
            result = c.getInt(2);
        }

        return result;
    }
}

This is the error message I get:

E/SQLiteLog: (1) table Estudiantes has no column named calificacion
E/SQLiteDatabase: Error inserting calificacion=80 nombre=Fer
android.database.sqlite.SQLiteException: 
table Estudiantes has no column named calificacion (code 1): , while compiling: 
INSERT INTO Estudiantes(calificacion,nombre) VALUES (?,?)
READ  [FIXED] java - Application crashes when item from searchable spinner is selected
Powered by Inline Related Posts
Android Tags:android, java, sqlite

Post navigation

Previous Post: [FIXED] java – MVVM with Room and LiveData – How to get List from LiveData
Next Post: [FIXED] android – Xamarin.Forms.Droid Resource, Ambiguous Terms/ Build Action’s Randomly Changing Missing Resources

Related Posts

[FIXED] firebase – Fetch Array values from firestore using Android Studio Android
[FIXED] leaflet – Flutter – Map blank in device Android Android
[FIXED] android – How to make Links inside EditText not Clickable Android
[FIXED] java – Finding date of next Thursday in android studio Android
[FIXED] android – I am getting a java.lang.IllegalArgumentException: Unknown color Android
[FIXED] How to make a share button in android – Kotlin Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • What color are dead flea eggs?
  • What is Indiana vine?
  • What’s the downside of a Chromebook?
  • Is phosphide the same as phosphorus?
  • Why do you need an S bend?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme