想法就在这里,但是它没有用,很热,做得对,我是一个完全乞讨的人)
String temperature = editText5.getText().toString();
String percent = editText7.getText().toString();
Cursor c1 = db.query("mytable", null, "temperature, percent = ?", new String[]{temperature, percent}, null, null, null);
if (c1.moveToFirst()) {
int ckoef = c1.getColumnIndex("ckoef");
int density = c1.getColumnIndex("density");
do {
textView9.setText(c1.getString(ckoef));
textView11.setText(c1.getString(density));
} while (c1.moveToNext());
} else
c1.close();
表格如下所示
ID = 1, temperature = 0, percent = 10, ckoef = 4.025, density = 1012.5
ID = 2, temperature = 10, percent = 10, ckoef = 4.034, density = 1012.5
ID = 3, temperature = 20, percent = 10, ckoef = 4.043, density = 1012.5
ID = 4, temperature = 30, percent = 10, ckoef = 4.057, density = 1012.5
ID = 5, temperature = 40, percent = 10, ckoef = 4.075, density = 1012.5
ID = 6, temperature = 50, percent = 10, ckoef = 4.085, density = 1012.5
ID = 7, temperature = 60, percent = 10, ckoef = 4.094, density = 1012.5
ID = 8, temperature = 70, percent = 10, ckoef = 4.103, density = 1012.5
ID = 9, temperature = 80, percent = 10, ckoef = 4.113, density = 1012.5
ID = 10, temperature = 90, percent = 10, ckoef = 4.122, density = 1012.5
ID = 11, temperature = 100, percent = 10, ckoef = 4.132, density = 1012.5
等,10-50的百分比,步骤10
所以请帮忙。
答案 0 :(得分:0)
使用游标
查询sqlite数据库Cursor c1 = db.query("mytable", null, "temperature=? and percent=?", new String[] { temperature, percent }, null, null, null);
其中new string[]
分别代表温度和百分比值的值
答案 1 :(得分:-1)
光标c1 = db.query(" mytable",null," temperature =?和percent =?&#34 ;, temperature,percent,null,null,null);