0

This is part of my database. I followed the position of the columns but there's still an error.

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;
    }
3
  • What is your error? Also COLUMN_DATE type is missing. Commented Jul 10, 2016 at 13:53
  • Error:(112, 24) error: no suitable constructor found for Note(String,String,String,Category,long,long) constructor Note.Note(String,String,Category) is not applicable (actual and formal argument lists differ in length) constructor Note.Note(String,String,Category,long,long) is not applicable (actual and formal argument lists differ in length) +Misagh Commented Jul 10, 2016 at 13:54
  • missing from where +Misagh Commented Jul 10, 2016 at 13:54

2 Answers 2

2

You are missing thoughts in constructor input parameters. Change it to this:

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;
    }
Sign up to request clarification or add additional context in comments.

1 Comment

Oh yes ! Thank you so much!!
1

Third parameter of Note() constructor is type of Category, but you passed it a String (returned by cursor.getString(3) method)

2 Comments

isn't my third parameter COLUMN_THOUGHTS?
Yes, in your table. But no in your constructor. I think you made a mistake in your constructor. add "thoughts" to your constructor in third place.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.