fetching data from database and set it on edittext

夙愿已清 提交于 2019-12-11 04:17:22

问题


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?


回答1:


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);



回答2:


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()



来源:https://stackoverflow.com/questions/9630859/fetching-data-from-database-and-set-it-on-edittext

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!