In my Android application I have a TextView with an EditText. I want to prepopulate the EditText with the last value entered, which is stored in the SQLite database?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
I have done this By using
Spinner
insideEditText
.Take
EditText
andSpinner
inside aRelativeLayout
retrieve data from DB and assign those values to the spinner.By using
OnItemSelectedListener
to the spinner u can assign the selected values to urEdiText
.This should not be so hard I think:
If you want to learn more about SQLite database storage, read this article in Android document.
Assign an edittext to it's resource ID via
getViewById(R.id.xxxx)
then do a SQLite query for the highest PID...
then pull theString you're looking for out of the result cursor...
assign that via editTextId.setText(theString);
be sure to enclose it in a try/catch and assign the edittext to some arbitrary default value if the db exec fails due to no entries in the table.