Search code examples
androidgoogle-mapsfirebasefirebase-realtime-databasegoogle-polyline

Saving decoded polylines into a firebase database in android


I have already seen the code to store a single point in firebase. But what I want to know is how to store whole polylines in firebase database? A decoded polyline is basiclly List. I want to know how to store many such type of lists in firebase so that I can retrieve later and perform operations on whole polyline.


Solution

  • Firebase use JSON format Database

    Pass types that correspond to the available JSON types as follows:

    • String

    • Long

    • Double

    • Boolean

    • Map

    • List

    you can pass any of data type a value in setValue() method and Lists and Map ,too.

    Example:

    Firebase ref = new Firebase("<my-firebase-app>/names"):
    String[] names = {"John","Tim","Sam","Ben"};
    List nameList = new ArrayList<String>(Arrays.asList(names));
    // Now set value with new nameList
    ref.setValue(nameList);
    

    you can pass your custome object list,too.