2016-07-10 5 views
0

Dies ist ein Teil meiner Datenbank. Ich folgte der Position der Spalten, aber es ist immer noch ein Fehler.Datenbank Cursor und Fehler mit Spalten

public static final String CREATE_TABLE_NOTE = "create table " + NOTE_TABLE + " (" 
     + COLUMN_ID + " integer primary key autoincrement, " 
     + COLUMN_TITLE + " text not null, " 
     + COLUMN_MESSAGE + " text not null, " 
     + COLUMN_THOUGHTS + " text not null, " 
     + COLUMN_CATEGORY + " text not null, " 
     + COLUMN_DATE + ");"; 


private Note cursorToNote(Cursor cursor){ 

//this part is underlined in red(error) 

Note newNote = new Note (cursor.getString(1), cursor.getString(2),cursor.getString(3), 
         Note.Category.valueOf(cursor.getString(4)), cursor.getLong(0), cursor.getLong(5)); 
       return newNote; 
      } 

Note.java

public Note (String title, String message, Category category, long noteId, long dateCreatedMilli){ 
     this.title = title; 
     this.message = message; 
     this.thoughts = thoughts; 
     this.category = category; 
     this.noteId = noteId; 
     this.dateCreatedMilli = dateCreatedMilli; 
    } 
+0

Was ist Ihr Fehler? Auch der 'COLUMN_DATE' Typ fehlt. –

+0

Fehler: (112, 24) Fehler: kein geeigneter Konstruktor gefunden für Note (String, String, String, Kategorie, long, long) Konstruktor Note.Note (String, String, Category) ist nicht anwendbar (tatsächliches und formales Argument Listen unterscheiden sich in der Länge) Konstruktor Note.Note (String, String, Kategorie, lang, lang) ist nicht anwendbar (tatsächliche und formale Argumentlisten unterscheiden sich in der Länge) + Misagh –

+0

fehlt von wo + Misagh –

Antwort

1

dritte Parameter von Note() Konstruktor Art von Category, aber man gab sie ein String (zurück nach cursor.getString(3) Methode)

+0

ist nicht mein dritter Parameter COLUMN_THOUGHTS? –

+0

Ja, in Ihrer Tabelle. Aber nein in deinem Konstruktor. Ich denke du hast einen Fehler in deinem Konstruktor gemacht. Fügen Sie Ihrem Konstruktor an dritter Stelle "Gedanken" hinzu. –

2

Sie vermissen thoughts in Konstruktor Eingangs Parameter. Ändern Sie es zu diesem:

public Note (String title, String message, String thoughts, Category category, long noteId, long dateCreatedMilli){ 
     this.title = title; 
     this.message = message; 
     this.thoughts = thoughts; 
     this.category = category; 
     this.noteId = noteId; 
     this.dateCreatedMilli = dateCreatedMilli; 
    } 
+0

Oh ja! Ich danke dir sehr!! –