I\'m making an application Maps connected with SQLite which there are markers, but there is an error that the database can not be recognized, why did it happen? Can anybody help
Marker.db
should be the name of your database and you should pass it in your constructor. The name of your table should be simply Marker
:
public class MaBase extends SQLiteOpenHelper {
private static final String DB_MARK ="marker.db";
private static final String TABLE_MARK ="marker";
private static final String COL_ID = "ID";
private static final String COL_LONG = "LONGITUDE";
private static final String COL_LAT = "LATITUDE";
private static final String CREATE_BDD = "CREATE TABLE " + TABLE_MARK + " ("
+ COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COL_LONG + " TEXT NOT NULL, " +COL_LAT+" TEXT NOT NULL);";
public MaBase (Context context, String name, CursorFactory factory, int version) {
super(context, DB_MARK, factory, 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);
}
...
marker.db
as a table name tells to look up a table name db
in database marker
and you don't have the database marker
attached.
Either write the table name in double quotes like "marker.db"
, or better yet, rename the table to something that better resembles whatever you're putting in there, without a .
.