1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Error en insert de SQLlite, android.database.sqlite.SQLiteException: no such table: CLTABLE...

Discussion in 'Programming/Internet' started by Jairo, Oct 8, 2018.

  1. Jairo

    Jairo Guest

    Hola tengo un error al insertar datos a una tabla en SQLlite, muestra el siguiente error:


    android.database.sqlite.SQLiteException: no such table: materias (code 1): , while compiling: INSERT INTO materias(descrip,materia,titulo,user_fk,fecha_lim) VALUES (?,?,?,?,?)

    Este es mi DatabaseHelper

    public DatabaseHelper(Context context) {
    super(context, "agenda.db", null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
    db.execSQL("Create table user (id INTEGER PRIMARY KEY AUTOINCREMENT, user_name Text, user_email Text, user_password Text)");
    db.execSQL("Create table materias (id INTEGER PRIMARY KEY AUTOINCREMENT, user_fk INTEGER not null, materia Text, titulo Text, descrip Text,fecha_lim Text, estado Text)");

    }
    public boolean insertmat(Integer user_fk, String materia, String titulo, String descrip, String fecha_lim){
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues contentValues = new ContentValues();
    Integer user = Integer.valueOf(user_fk);
    contentValues.put("user_fk", user);
    contentValues.put("materia", materia);
    contentValues.put("titulo", titulo);
    contentValues.put("descrip", descrip);
    contentValues.put("fecha_lim", fecha_lim);
    long ins = db.insert("materias", null, contentValues);
    if(ins==1) return false;
    else return true;
    }


    Este es mi java

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab_addtar_task);
    fab.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    String tar = tarea.getText().toString();
    String mat = materia1.getText().toString();
    String des = desc.getText().toString();
    String fec = fecha.getText().toString();
    Integer userid = Integer.valueOf(session.getid());
    if(tar.equals("") || mat.equals("") || des.equals("") || fec.equals("")){
    Toast.makeText(getApplicationContext(),"No dejes ningun campo vacio", Toast.LENGTH_SHORT).show();
    }
    else {
    Boolean insert1 = db.insertmat(userid,mat,tar,des,fec);
    if(insert1==false){
    Toast.makeText(getApplicationContext(),"Materia Registrada Con Exito", Toast.LENGTH_SHORT).show();
    }
    else{
    Toast.makeText(getApplicationContext(),"Error", Toast.LENGTH_SHORT).show();
    }
    }
    }
    });

    Login To add answer/comment
     

Share This Page