Android:构造函数未定义?

时间:2014-07-21 11:33:55

标签: android sqlite constructor

在以下活动(SQLite databaseHelper类)中,我收到错误:

The Constructor Score(String, int, int, long) is undefined

当我在Score类中添加一个新的实例var时,问题就出现了。这是我将要插入我的数据库的对象。

它的构造函数和inst vars现在如下:

package com.example.brianapp;

import java.io.Serializable;

//note: serializable was imported to attempt to pass an object from mediation and meditationresults
public class Score implements Serializable {
    String name;
    int meditation;
    int max;
    int score;
    long date;

    public Score() {

    }

    public Score(String name, int meditation, int max, int score, long date) {
        this.name = name;
        this.meditation = meditation;
        this.max = max;
        this.score=score;
        this.date = date;
    }
}

我在数据库Helper类中获取语法错误的代码块是:

/**
     * Method will return a single Name and score
     * 
     * @param id
     * @return
     */
    // Getting single contact
    Score getScore(String name) {
        SQLiteDatabase db = this.getReadableDatabase();

        Cursor cursor = db.query(TABLE_SCORE, new String[] { COL_NAME,
                COL_MED, COL_MAX, COL_SCORE, COL_DATE }, COL_NAME + "=?",
                new String[] { String.valueOf(name) }, null, null,null,null,null);
        if (cursor != null)
            cursor.moveToFirst();

        Score score = new Score(cursor.getString(0),Integer.parseInt(cursor
                .getString(1)),Integer.parseInt(cursor.getString(2)),Integer.parseInt(cursor.getString(3)), cursor.getLong(4));
        // return contact
        return score;
}

我该如何解决这个问题?

0 个答案:

没有答案