Import data into Firebase with JSON file

0

I'm having problems with importing data into firebase, I've converted an excel spreadsheet into csv and then converted it to a JSON file, the Firebase registration is done normally, but I'd like to know how to generate the keys with the data, rather than putting up a numerical order. If anyone knows of a solution thank you right away.

Import of JSON

FormattingwiththeKeys

    
asked by anonymous 11.01.2018 / 05:02

1 answer

0

Keys are generated through the push() function in DatabaseReference. On android, you can generate them through the code:

private DatabaseReference mDatabase;
// ...
mDatabase = FirebaseDatabase.getInstance().getReference();
String key = mDatabase.child("Productos").push(); // esta é a key
mDatabase.child("Productos").child(key).setValue(/*O producto que você quer salvar*/);

You can find more details in the documentation .

    
11.01.2018 / 08:11