sqlite db にエントリを挿入しようとしましたが、一部のデバイスでは機能しません! 挿入はデバイスHuawei Nexus 6P (Android 6.0, API23) ではうまく機能しますが、デバイスSamsung SM-G930F (Android 6.0.1, API23) では機能しません。
手伝ってくれませんか!戻りコードは常に「res = -1」です。新しい登録を挿入するための私のコードは次のとおりです。
public boolean insertRegistration(登録登録) {
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;
}
デバッガもキャッチに来ません!警告やエラーは返されません。
そして、データベースは次のようになります。
@Override public void onCreate(SQLiteDatabase db) { db.execSQL(DATABASE_CREATE_USER); }
ユーザー データベース文字列を作成します。
private static final String DATABASE_CREATE_USER = "テーブルを作成する" + 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" + ");";
この行「res = db.insert(TABLE_USER, null, cv);」をデバッグすると、常にリターン コード「-1」が返されます。デバイス「Samsung SM-G930F」で。
前もって感謝します!