FireNewbie
FireNewbie

Reputation: 123

Save an EditText value into Firebase on Android

I want to send a EditText (message) into the Firebase database. I can save a string but it does not work with a text area here is my code:

Map<String, Object> updates = new HashMap<String, Object>();
updates.put("Your Message: ", textArea);
f.setValue(updates);

So I want to save a text area to the Firebase database. I also want to know how I can send it to a specific entity for example.

save at Name: mystring or at ID: myid if there is a way to use JSON. I am new to Firebase.

Upvotes: 1

Views: 4670

Answers (1)

mimming
mimming

Reputation: 13954

It sounds like you're working with an Android EditText view.

You probably don't want to store all of the state in Firebase, just the string value. The code to do that in Firebase would look something like this:

EditText myEditText = (EditText)findViewById(R.id.my_edit_text);

Firebase mFirebaseRef = 
    new Firebase("https://<your-firebase>.firebaseio.com/some/path");

myFirebaseyRef.setValue(myEditText.getText().toString());

Upvotes: 6

Related Questions