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 –