我正在尝试在Android中的SQLite数据库中添加或更新信息。 数据库采用课程注释ID和学生ID。如果课程注释id为0,则表示正在创建新条目。
这是我的Dbhelper类中的内容(对于插入,更新非常相似):
public boolean insertLessonNotes(LessonNotesData lData)
{
SQLiteDatabase db = this.getWritableDatabase();
ContentValues lessonValues = new ContentValues();
//values.put(LESSON_ID, lData.getLessonID()); // Lesson ID
//values.put(ST_ID, lData.getStudentID()); // Student ID
//values.put(LESSON_IMAGE_ID, lData.getImageID()); // Lesson Image ID
//values.put(LESSON_IMAGE_NOTE, lData.getImageNote()); // Note attached to image
lessonValues.put(LESSON_ID, lData.getLessonID());
lessonValues.put(ST_ID, lData.getStudentID());
lessonValues.put(DATE, lData.getDate()); // Date note added
lessonValues.put(LESSON_READING, lData.getReadingNote()); // reading notes
lessonValues.put(LESSON_PHONICS, lData.getPhonicsNote()); // phoncis notes
lessonValues.put(LESSON_SPELLING, lData.getSpellingNote()); // spelling notes
lessonValues.put(LESSON_WRITING, lData.getWritingNote()); // writing notes
lessonValues.put(LESSON_COMMENTS, lData.getCommetns()); // comments notes
lessonValues.put(LESSON_HOMEWORK, lData.getHomework()); // homework notes
// Inserting Row
db.insert(TABLE_LESSON_NOTES, null, lessonValues);
db.close();
return true;
}
这是我的lessonNotes类(输入和保存信息的地方)
LessonNotesData lNote = new LessonNotesData(id_To_Update, student_id, lessonDate.getText().toString(), readNote.getText().toString(), phonNote.getText().toString(), spellNote.getText().toString(), writeNote.getText().toString(), commentNote.getText().toString(), homeworkNote.getText().toString());
Bundle extras = getIntent().getExtras();
int studentID = extras.getInt("studentId");
int lessonID = extras.getInt("lessonID");
Toast.makeText(getApplicationContext(), "LessonID is:(lessonNotes3) "+String.valueOf(lessonID), Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), "StudentID is: (lessonNotes3) "+String.valueOf(studentID), Toast.LENGTH_SHORT).show();
//Bundle studentId = getIntent().getExtras();
if (lessonID != 0) {
if (studentID > 0) {
if (mydb.updateLessonNotes(lNote)) {
//Update was successful
Toast.makeText(getApplicationContext(), "Updated successfully", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(getApplicationContext(), com.example.ltss.dyslexia.app.LessonNotesList.class);
intent.putExtra("studentId",studentID);
startActivity(intent);
} else {
//Update did not complete correctly
Toast.makeText(getApplicationContext(), "Update unsuccessful, Please try again", Toast.LENGTH_SHORT).show();
}
} else {
if (mydb.insertLessonNotes(lNote)) {
Toast.makeText(getApplicationContext(), "New Lesson note created", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getApplicationContext(), "Error creating lesson note! Please try again", Toast.LENGTH_SHORT).show();
}
//Return user to lessonNotesList where ListView should now show new lesson note
Intent intent = new Intent(getApplicationContext(), com.example.ltss.dyslexia.app.LessonNotesList.class);
intent.putExtra("studentId",studentID);
startActivity(intent);
}
}
每当我尝试在系统中添加或更新任何内容时,我都会从调试日志中获取:
04-02 20:02:33.925 26789-26789/com.example.ltssdyslexiaapp D/Items to add:﹕ com.example.ltss.dyslexia.app.LessonNotesData@42602bf8
关于这是什么或如何解决它的任何想法?
谢谢
答案 0 :(得分:0)
实际上它不是一个错误,只是一个Log输出,它是一个DEBUG类型的Log。你colud尝试记录相同的添加行android.util.Log.d(" hello"," world");你想要的任何方法。并且' com.example.ltss.dyslexia.app.LessonNotesData@42602bf8'表示LessonNotesData没有toString()方法,这就是为什么你看到@ 42602bf8 - 它在内存或散列中的实例地址。