Reputation: 47
i create a database and a table. This went well.
// Create Database
matDb = SQLiteDatabase.openOrCreateDatabase(path + "/test.db", null);
matDb.execSQL("CREATE TABLE IF NOT EXISTS " + ammTbl + "(werk text, matnum text, mattxt text, unit text, loc text, chargenpflicht text)");
On the device I can find the database and the table. I inserted data. The object mh has the values!:
matDb.beginTransaction();
ContentValues row = new ContentValues();
row.put("werk", plant);
row.put("matnum", mh.getMatnum());
row.put("unit", mh.getUnit());
row.put("mattxt", mh.getMattxt());
matDb.insertOrThrow(ammTbl, null, row);
matDb.setTransactionSuccessful();
matDb.endTransaction();
matDb.close();
An exception didn't raise. No data is inserted. What am I doing wrong?
Upvotes: 0
Views: 38
Reputation: 214
You @LittleProgrammer need to do
matdb=getWritableDatabase();
before inserting the values into the table
Upvotes: 1