安卓从数据库中读取输入文本框的内容 怎么读?

public class MainActivity extends AppCompatActivity {
private SQLiteDatabase db;
private final String DATABASE_PATH = "/mnt/mmcblk1/mmcblk1p1/SQL";
private String DATABASE_FILENAME = "song.db";
private EditText eT;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    String databaseFilename = DATABASE_PATH + "/" + DATABASE_FILENAME;
    eT = (EditText)findViewById(R.id.EDT);
    //       db = openOrCreateDatabase("song.db", Context.MODE_PRIVATE, null);
    db = SQLiteDatabase.openOrCreateDatabase(databaseFilename, null);
    new Thread(new Runnable() {
        @Override
        public void run() {
            Cursor c = null;
            c = db.rawQuery("SELECT * FROM song where SongName like "+ eT , null);
            while (c.moveToNext()) {
                String name = c.getString(c.getColumnIndex("SongName"));
                Log.i("db", " SongName= " + name);
            }
        }
    }).start();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}

}


这是我写的代码 想在界面中输入一两个字对应查找数据库中的数据 我知道现在写的这个是不对的 要怎么写啊 求指点!!!!!!!!!

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐