1

There is a requirement for download the database data as a .CSV file. How can I get data from Firebase realtime database and convert it to .CSV format in Android?

Firebase only gave manual download database in JSON format.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
Anjuka Koralage
  • 309
  • 3
  • 14

1 Answers1

1

If you are looking for button that allows you download your database in another format than JSON, there isnt't one. To solve you should do your yourself. So according to your database schema, you should write custom code that will help you convert a JSON file to a CSV file. A possile solution might be, Sridhar's answer from the following post:

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
  • But the 1st problem is cannot get json file from firebase, Is there any way to download json from firebase – Anjuka Koralage Jul 31 '19 at 08:52
  • 1
    Yes, you can do that directly from the [Firebase console](https://console.firebase.google.com/). Select your project -> Select Database -> Select **Realtime Database** -> Click on the three dots -> Export JSON. Does it work now? – Alex Mamo Jul 31 '19 at 09:08
  • thanks, but I need to download it via my android application. That is the actual problem. – Anjuka Koralage Jul 31 '19 at 09:34
  • 1
    In that case, you need to iterate over your entire database according to your database schema. Check the official documentation regarding [retrieving data in Firebase realtime database](https://firebase.google.com/docs/database/admin/retrieve-data). Once you have that data, convert it to a `CSV` file and write locally, that's it. – Alex Mamo Jul 31 '19 at 09:59