@Override
public void onClick(View view) {
String str1="";
EditText editText1=(EditText)findViewById(R.id.zyss);
str1=editText1.getText().toString();
TextView textView = (TextView)findViewById(R.id.TextView1);//
//String path=Environment.getExternalStorageDirectory()+"/sj.db";
//textView.setText(MainActivity2.this.getDatabasePath("mydata.db").getPath());//getDatabasePath("myadata.db").getPath()
//dbsj=SQLiteDatabase.openOrCreateDatabase(getDatabasePath("myadata.db").getPath(),null);//MainActivity2.this.getDatabasePath("mydata.db").getPath()
dbsj=myOpenHeleper.getWritableDatabase();
textView.setText("");
Cursor chazhao=dbsj.rawQuery("select * from zy where YFYL",new String[]{"like%"+str1+"%"});// like '%"+str1+"%'"
if (chazhao!=null&&chazhao.getCount()>0){
while(chazhao.moveToNext()){
String YM= chazhao.getString(1);
String YX= chazhao.getString(2);
String GJ= chazhao.getString(3);
String GX= chazhao.getString(4);
String YY= chazhao.getString(5);
String YFYL= chazhao.getString(6);
String ZY=chazhao.getString(7);
//System.out.print(YX);
textView.append(YM);
}
}
dbsj.close();
chazhao.close();
//第二种方法也改了很多次,照抄也是不行,前面到数据库路径那部分都是对的
SQLiteDatabase db=myOpenHeleper.getReadableDatabase();
Cursor cursor = db.query("zy",new String[]{"YM"},"YM=?",new String[]{"麻黄"},null,null,null);
while (cursor.moveToNext()){
String YM = cursor.getString(cursor.getColumnIndex("YM"));
String YX = cursor.getString(cursor.getColumnIndex("YX"));
String GJ = cursor.getString(cursor.getColumnIndex("GJ"));
String GX = cursor.getString(cursor.getColumnIndex("GX"));
String YY = cursor.getString(cursor.getColumnIndex("YY"));
String YFYL = cursor.getString(cursor.getColumnIndex("YFYL"));
String ZY = cursor.getString(cursor.getColumnIndex("ZY"));
Log.d("1055",YM+YX);
textView.setText(YX);
}
有没有异常日志,主要看日志来分析问题。