Hello! For the first time I create a SQLite database in android (based on the documentation). As a result, values.put underlines in red and writes cannot resolve symbol put. Also in the same expression does not recognize the class nwTABLE.

ContentValues ​​I create and use in a separate class

public final class newBASE { public newBASE (){} public static final String TEXT_TYPE = " TEXT"; public static final String COMA_SEP = ","; public static final String SQL_CREATE_ENTRIES = "CREATE TABLE" + nwTABLE.TABLE_NAME+ "("+nwTABLE._ID+"INTEGER PRIMARY KEY," + nwTABLE.COLUMN_NAME_ENTRY_ID + TEXT_TYPE + COMA_SEP + nwTABLE.TASK + TEXT_TYPE + COMA_SEP + nwTABLE.ANSWER + TEXT_TYPE + COMA_SEP + " )"; public static final String SQL_DELETE_ENTRIES = "DROP TABLE IF EXISTS" + nwTABLE.TABLE_NAME; public static abstract class nwTABLE implements BaseColumns { public static final String COLUMN_NAME_ENTRY_ID = "entire" public static final String TABLE_NAME = "mathprofi"; public static final String TASK = "task"; public static final String ANSWER = "answer"; } public static class TABLEHELPER extends SQLiteOpenHelper { public static final int DATABASE_VERSION = 1; public static final String DATABASE_NAME = "newBASE.db"; public TABLEHELPER (Context context) { super(context, DATABASE_NAME , null, DATABASE_VERSION); } public void onCreate (SQLiteDatabase db) { db.execSQL(SQL_CREATE_ENTRIES); } public void onUpgrade (SQLiteDatabase db, int oldVersion, int nerVersion){ db.execSQL(SQL_DELETE_ENTRIES); onCreate(db); } public void onDowngrade (SQLiteDatabase db, int oldVersion, int newVersion) { onUpgrade(db, oldVersion, newVersion); } } TABLEHELPER mTABLEHELPER = new TABLEHELPER(getContext()); SQLiteDatabase db = mTABLEHELPER.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(nwTABLE.TASK, task); values.put(nwTABLE.ANSWER, answer); } 
  • Offhand: the table itself is created with errors. There, every extra space can prevent its creation. First, the table should close ");", and not ")". Secondly, I do not see where your nwTABLE._ID variable is nwTABLE._ID , but the space between it and "INTEGER PRIMARY KEY" does not hurt :) On the merits of the question: where do you create and fill ContentValues ? Add to the question, it is not obvious - Jarvis_J
  • ContentValues ​​I create in a separate class. And since the nwTABLE class is abstract (this is what the documentation requires), I do not create an instance of the class - Andrey Dmitriev
  • at the same time, the BaseColumns interface import is complete ... - Andrei Dmitriev
  • @Jarvis_J The _ID constant is in the BaseColumns interface BaseColumns implemented - this is the standard android constant for the unique identifier, but the database creation string is incorrect. - pavlofff
  • I already saw one mistake - ContentValues, it was necessary, nevertheless, not to initiate there. I put it in OnCreate and stops underlining the put - Andrei Dmitriev

0