public class SearchActivity extends AppCompatActivity {
EditText recupdate;
Button update;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search);
recupdate = (EditText)findViewById(R.id.txtusername);
update = (Button)findViewById(R.id.btnupdate);
update.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
SQLiteDatabase fuuast = openOrCreateDatabase("MyDb", MODE_PRIVATE, null);
fuuast.execSQL("Create table if not exists std_rec(username varchar primary key, password varchar, age Integer, phone Integer) ");
String query = "Select * from std_rec Where username = '"+update.getText()+"'";
fuuast.execSQL(query);
Intent i = new Intent(getApplicationContext(), MainActivity.class);
Toast.makeText(getApplicationContext(), "", Toast.LENGTH_SHORT).show();
startActivity(i);
}
});
}
如何顯示數據或在哪裏顯示請幫我想顯示的數據點擊搜索按鈕對不起我的英語後,我是AB初學者如何從數據庫中檢索數據並在textview或toast中顯示或在警報中顯示?
你想在哪裏顯示數據?你能詳細說明一下嗎? – Akshay
任何地方在相同的活動或警報或彈出窗口或textview –
檢查下面的答案@AdilKhan –