Note that there are some explanatory texts on larger screens.

plurals
  1. PONo such table when wanting to insert data on SQLite database
    text
    copied!<p>I used to insert 2 values/columns in my sqlite db(coordinates/markers to show them on map), today i wanted to add another column, i added it as usual but when wanting to launch map activity i have a logcat error as:</p> <pre><code>08-23 13:27:30.001: ERROR/Database(300): android.database.sqlite.SQLiteException: no such table: coord: , while compiling: INSERT INTO coord(longitude, latitude, description) VALUES(?, ?, ?); </code></pre> <p>To create the db+table i'm using this code:</p> <p>public class MaBaseSQLite extends SQLiteOpenHelper {</p> <pre><code>private static final String TABLE_COORD = "coord"; private static final String COL_ID = "ID"; private static final String COL_LATI = "latitude"; private static final String COL_LONGI = "longitude"; private static final String COL_DESCRI = "description"; private static final String DATABASE_NAME = "coord.db"; private static final int DATABASE_VERSION = 1; private static final String CREATE_BDD = "CREATE TABLE " + TABLE_COORD + " (" + COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COL_LATI + " TEXT NOT NULL, " + COL_LONGI + " TEXT NOT NULL, " + COL_DESCRI + "TEXT NOT NULL);"; MaBaseSQLite(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { //on créé la table à partir de la requête écrite dans la variable CREATE_BDD db.execSQL(CREATE_BDD); } </code></pre> <p>To insert values i'm using this code in other class:</p> <pre><code>public long insertCoordo(Coordo coordo){ //Création d'un ContentValues (fonctionne comme une HashMap) ContentValues values = new ContentValues(); values.put(COL_LATI, coordo.getlati()); values.put(COL_LONGI, coordo.getlongi()); values.put(COL_DESCRI, coordo.getdescri()); //on insère l'objet dans la BDD via le ContentValues return bdd.insert(TABLE_COORD, null, values); } </code></pre> <p>Example adding:</p> <pre><code>Coordo coordo = new Coordo(36.876673,10.325928, "TOTAL La Marsa"); CoordBd.insertCoordo(coordo); </code></pre> <p>And coordinates has 3 values as mentionned in this code in coordo() class:</p> <pre><code>public Coordo(Double lati, Double longi,String descri){ this.lati = lati; this.longi = longi; this.descri= descri; } </code></pre> <p>What could be the problem with that?Why it can't insert values on the table cause it dodn't find it? Thanks for helping.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload