This is the code of my database class.
public class SQLite_OpenHelper extends SQLiteOpenHelper {
public SQLite_OpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
super(context, name, factory, version);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE t_emisiones(pais TEXT primary key, emision REAL);");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE t_emisiones");
onCreate(db);
}
This is where my app stops, when it arrives at (db.execSQL).
SQLite_OpenHelper dbhelp = new SQLite_OpenHelper(this,"emisores_paises", null, 1);
SQLiteDatabase db = dbhelp.getWritableDatabase();
db.execSQL("INSERT INTO t_emisiones VALUES('colombia', 0.205)");
db.execSQL("INSERT INTO t_emisiones VALUES('espana', 0.388)");
db.execSQL("INSERT INTO t_emisiones VALUES('mexico', 0.582)");
db.close();
I have been programming in Android Studio and I am very new, what I want to do is a database with values that I add as constants and then I can read them to work with them but adding the line of code to insert data is stop the app.
PS: suggestions in case it is better to work with fixes than by database.