In my alertdialog the user enters a comment on a Edittext. When I convert the Editext to an editable then save the editable, it works. However when I try to concat it with other values into a string, it does not save the editable. When I use .toByte when concating with the string, it saved the bytes. I put a // by where the code is that is not working.
Here is my code.
LayoutInflater inflater = LayoutInflater.from(this);
final EditText input = new EditText(this);
new AlertDialog.Builder(this)
.setTitle("Comments")
.setMessage("Enter Comments below")
.setView(input)
.setPositiveButton("Enter", new DialogInterface.OnClickListener() {
Editable value = input.getText();
String string= value.toString()+ " "+ parent[groupPosition] + " "
//it does not combined value.toString() to the string.
+ kids[groupPosition][childPosition];
@Override
public void onClick(DialogInterface dialog, int which) {
try {
FileOutputStream fos = openFileOutput("repairs",
Context.MODE_PRIVATE);
fos.write(string.toString().getBytes());
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
have you tried placing
inside your try block? As it’s currently written the
valuefield is obtained when the OnClickListener is initialised and won’t reflect the latest user input.