Reputation: 374
I am using firebase as backend for storage and authentication for the android app. I have created the authentication part. So, far it works well. The problem comes in database part.
My question here is:
I want to store list of names and address of client in the firebase database. How can it be done (Considering I have just a text file with 2 columns)? Can this be automated or should it be done manually? i.e. By creating a Location child and in that writing Name with name of client and Value as address. As the list is high is number how can this be automated?
Once the list is stored on database, I want to distribute specific number of address to specific users only. How can this be done through firebase? Is there any way to distribute say "first 10 names and address to user1" and next 10 to user2" and so on?
Fetch the address and names from database to the users as list and "feed it to Geolocation for validation" and "obtaining latitude and longitude" and "further sending it to Maps" for navigation.
That's it. This is the part I am struggling with.
Can you suggest an alternative to implement this?
Upvotes: 0
Views: 73
Reputation: 139019
Here are the answers.
(i) If you can convert your text file into a JSON formatted file
, then you can upload it very simple using your Firebase console -> Database -> Import JSON. The structure must be as a pair, of key and value.
(ii) Yes you can do it. You need to create a Map
for names
and a Map
for address
like this:
Map<String, Object> map = new HashMap<>();
map.put("name1", name1);
map.put("name2", name2);
........................
map.put("name10", name10);
yourRef.child(userId).child("names").updateChildren(map);
"name1", "name2" ... "name10"
can be also changed with ids. You can use a method named push() which generates unique keys. Also userId
is the id of the specific user for which you want to assign the names.
(iii) Yes, you can achieve that too. You can take a look at this post.
Hope it helps.
Upvotes: 1