fetching data from database and set it on edittext

2019-08-05 15:40发布

I am doing a registration page for my application.For this I need to insert the registration details in to sqlite DB.Once the registration is done,the edittext fields should display those details fetching it from database and the submit button and text fields should be disabled to stop from a second time registration.Can anyone suggest the suitable way?

2条回答
冷血范
2楼-- · 2019-08-05 15:55

Check code for database in the following link Android SQLite

You have to store the value in an arraylist and which is retrieved from database and set the value to the edit text as

// myarraylist is the arraylist which contains 
// the data retrieved from database
editText.setText(myarraylist.get(0)); 

After the data is retrieved, you have to check the condition whether editText.getText().toString() length is greater then zero you should not allow them to edit the text in editText by using following

  editText.setFocusable(false);
查看更多
神经病院院长
3楼-- · 2019-08-05 16:15

You can write/read into database easily: read this for more details: http://developer.android.com/guide/topics/data/data-storage.html#db and this http://mobile.tutsplus.com/tutorials/android/android-sqlite/

To get data from edit text, you can do this: myEditText.getText().toString()

查看更多
登录 后发表回答