为什么没有检测到Get方法?

时间:2016-04-21 16:07:28

标签: java android methods get

   import android.content.*;
   import android.database.*;
   import android.database.sqlite.SQLiteDatabase;
   import android.database.sqlite.SQLiteOpenHelper;
   import android.util.Log;

   public class DBAdapter extends SQLiteOpenHelper {



private static final int DATA_VERSION = 1;
private static final String DATABASE_NAME = "database.db";
public static final String TABLE = "table";
public static final String COLUMN_CONDUCTIVITY ="Conductivity";
public static final String COLUMN_OXYGEN = "Oxygen";
public static final String COLUMN_PH = "pH";
public static final String COLUMN_USERNAME = "username";
public static final String COLUMN_PASSWORD = "password";
public static final String COLUMN_MOISTURE = "moisture";

public DBAdapter(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
    super(context, DATABASE_NAME, factory, DATA_VERSION);
}

public DBAdapter(Context context, String name, SQLiteDatabase.CursorFactory factory, int version, DatabaseErrorHandler errorHandler) {
    super(context, name, factory, version, errorHandler);
}

@Override
public void onCreate(SQLiteDatabase db) {

    String query = "CREATE TABLE" + TABLE + "(" +
            COLUMN_CONDUCTIVITY+ " FLOAT" +
            COLUMN_OXYGEN+ " INTEGER" +
            COLUMN_PH+ "FLOAT " +
            COLUMN_USERNAME+ "STRING PRIMARY KEY " +
            COLUMN_PASSWORD + "TEXT" +
            COLUMN_MOISTURE+ " INTEGER "+
            ");";

    db.execSQL(query);
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    db.execSQL("DROP_TABLE_IF_EXITS" + TABLE);
    onCreate(db);
}
//Add a new row to the database
public void addData(DBAdapter data){
    ContentValues values = new ContentValues();
    values.put(COLUMN_CONDUCTIVITY, data.getConductivity

    values.put(COLUMN_OXYGEN, data.getOxygen());
    values.put(COLUMN_PASSWORD, data.getPassword());
    values.put(COLUMN_USERNAME, data.getUsername());
    values.put(COLUMN_PH, data.getPh());

    SQLiteDatabase db = getWritableDatabase();
    db.insert(TABLE, null, values);
    db.close();
}
//Delete data

public void deleteData(){
    SQLiteDatabase db = getWritableDatabase();
    db.execSQL("DROP TABLE IF EXIST, TABLE");
}
public String databaseToString(){

    String dbString = "";
    SQLiteDatabase db = getWritableDatabase();
    String query = "SELECT * FROM" + TABLE + "WHERE 1";
    Cursor c = db.rawQuery(query,null);
    c.moveToFirst();
    while(!c.isAfterLast()){
        if(c.getString(c.getColumnIndex("Conductivity"))!= null){
            dbString += c.getString(c.getColumnIndex(("Conductivity")));
            dbString += "\n";
        }
    }
    db.close();
    return dbString;

}

}

上面的代码没有从下面的代码中检测到get方法,是的,它们在同一个项目中。可以找到任何吸气剂。

有人可以帮忙吗?

请我尝试使用这个SQLite数据库。

public class DatabaseList {



    private String username;
    private String password;
    private float conductivity;
    private float pH;
    private int oxygen;
    private String date;

    public DatabaseList(){}

    public DatabaseList(String username, String password, String date, int oxygen, float pH, float conductivity){
        this.conductivity = conductivity;
        this.date = date;
        this.oxygen = oxygen;
        this.password = password;
        this.pH = pH;
        this.username = username;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public float getConductivity() {
        return conductivity;
    }

    public void setConductivity(float conductivity) {
        this.conductivity = conductivity;
    }

    public float getpH() {
        return pH;
    }

    public void setpH(float pH) {
        this.pH = pH;
    }

    public int getOxygen() {
        return oxygen;
    }

    public void setOxygen(int oxygen) {
        this.oxygen = oxygen;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }
}

1 个答案:

答案 0 :(得分:1)

好吧,DBAdapter类和Database列表甚至不是同一类类型, DBAdapter类是否为

getOxygen () 

方法?我不这么认为...... 这就是错误 你试图在另一个类中调用未定义的方法..