显示SqLite在文本字段中选择值

时间:2015-08-10 12:42:56

标签: android sqlite

我正在尝试在文本字段中显示SQLite表值。这是我的代码,但它不起作用。我有两个字段的表(SAP_DRQ_TABLE)(SAP_DRQ_KEY_METROLAC,SAP_DRQ_KEY_DRC)。

DBHelper.java

private static final String SAP_DRQ_TABLE = "sap_drq";
public static final String SAP_DRQ_KEY_METROLAC = "metrolac";
public static final String SAP_DRQ_KEY_DRC= "drc";

public List<SAP_DRQDatamodel> SAP_DRQDatamodel() {
        // TODO Auto-generated method stub
        List<SAP_DRQDatamodel> drc = new ArrayList<SAP_DRQDatamodel>();

        // Select All Query
        String selectQuery = "SELECT  * FROM " + SAP_DRQ_TABLE +" where"+SAP_DRQ_KEY_METROLAC+"='50'" ;

        SQLiteDatabase db = this.getReadableDatabase();
        Cursor cursor = db.rawQuery(selectQuery, null);

        // looping through all rows and adding to list
        if (cursor.moveToFirst()) {
            do {
                SAP_DRQDatamodel codes = new SAP_DRQDatamodel();
                codes.setdrc(cursor.getString(cursor.getColumnIndex(SAP_DRQ_KEY_DRC)));
            } while (cursor.moveToNext());
        }

        // closing connection
        cursor.close();
        db.close();
        // returning lables
        return drc;
    }

dashbord.java

DBHelper db = new DBHelper(getApplicationContext());
List<SAP_DRQDatamodel> DRQval= db.SAP_DRQDatamodel();
for (SAP_DRQDatamodel DRQ : DRQval){
    mDRQ.setText(DRQ.getdrc());
}

SAP_DRQDATAMODEL

public class SAP_DRQDatamodel {

    public String getmetrolac() {
        return metrolac;
    }

    public void setmetrolac(String metrolac) {
        this.metrolac = metrolac;
    }

    public String getdrc() {
        return drc;
    }

    public void setdrc(String drc) {
        this.drc = drc;
    }

    public String metrolac="", drc="";

}

1 个答案:

答案 0 :(得分:0)

问题是您的选择查询

for n in numpy.logspace(2,9,num=9-2, endpoint=False):
    test(n)