如何获取变量text1
,text2
并time
在开始时只显示一次,例如标题,因为它们对于特定的数据组具有相同的值,然后在下面显示变量text3
,因为该变量具有该特定数据组的值。
写入数据完成text3
后,对于该组数据,查询必须开始写入另一组数据,text1
,text2
和time
的新值text3
。
这是我的代码:
public class NapredakActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.first);
String var;
final TextView t = (TextView) findViewById(R.id.textView2);
Intent intent = getIntent();
var=intent.getStringExtra("date");
SQLiteDatabase db = openOrCreateDatabase("Database", MODE_PRIVATE, null);
String q = "SELECT text1 ,text2, text3, time FROM table WHERE time LIKE '"+var+"'";
Cursor c = db.rawQuery(q, null);
if( c.getCount() < 1 ){
c.close();
db.close();
Toast.makeText(NapredakActivity.this, "wrong choice",Toast.LENGTH_LONG).show();
startActivity(new Intent(this,calendar.class));
}
else{
String j="";
c.moveToFirst();
do {
String cm = c.getString(c.getColumnIndex("text1" ));
String cm2 = c.getString(c.getColumnIndex("text2"));
String cm4 = c.getString(c.getColumnIndex("text3"));
String cm3 = c.getString(c.getColumnIndex("time" ));
j = j+"\n"+cm+cm4+cm2+cm3;
} while (c.moveToNext());
t.setText(j);
c.close();
db.close();
} } }