1

I try to insert an entry in sqlite db, but this does not work on some devices! The insertion works with the device Huawei Nexus 6P (Android 6.0, API23) very well, but not with the device Samsung SM-G930F (Android 6.0.1, API23).

Can you please help me! The return code is always "res = -1". Here is my code for inserting a new registration:

public boolean insertRegistration(Registration registration) {

    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues cv = new ContentValues();
    cv.put("phoneNumber", registration.getPhoneNumber());
    cv.put("serverPassword", registration.getServerPassword());
    cv.put("chatPassword", registration.getChatPassword());
    cv.put("username", registration.getUsername());
    cv.put("fileURL", registration.getFileURL());

    long res = 0;
    try
    {
        res = db.insert(TABLE_USER, null, cv);
    }
    catch(SQLException e)
    {
        // Sep 12, 2013 6:50:17 AM
        Log.e("Exception", "SQLException" + String.valueOf(e.getMessage()));
        e.printStackTrace();
    }

    if(res == -1)
        throw new RuntimeException("New registration can not be inserted into local db");
    db.close();
    return res >= 0;
}

The debugger will also not come to the catch! No warning or errors will be returned!

And the db looks like this:

@Override
public void onCreate(SQLiteDatabase db) {
    db.execSQL(DATABASE_CREATE_USER);
}

Create user db string:

private static final String DATABASE_CREATE_USER = "create table " + TABLE_USER + "(" + "id integer primary key autoincrement, " + "phoneNumber text not null, " + "serverPassword text not null, " + "chatPassword text not null, " + "fileURL text not null, " + "username text not null" + ");";

I always get the return code "-1", if I debug this line "res = db.insert(TABLE_USER, null, cv);" on the device "Samsung SM-G930F".

Thank you in Advance!

atas priv
  • 41
  • 3

0 Answers0