简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM