Import data to Firebase with JSON file

Asked

Viewed 920 times

0

I am having problems with importing data to firebase, I transformed an excel spreadsheet into csv and then converted to a JSON file, the registration in Firebase is performed normally, but I would like to know how to generate the Keys with the data, instead of putting together a numerical order. If anyone knows of a solution I thank you at once.

Import from the JSON

inserir a descrição da imagem aqui

Format with the Keys

inserir a descrição da imagem aqui

1 answer

0

The Keys are generated through the function push() in Databasereference. On android, you can generate them through 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.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.