1

Hello I'm a beginner in programming. I studied Java and now I'm learning android.

I'm building an app with a 5 predefined users (My family), there will be a data exchange between these 5 users through a database connected to the internet. (After I searched the internet for a free online database I found Firebase; I hope it's the right choice).

Now I want to set 5 data files for each User (each files will contain data that the user will control)

So for each user it will be a view which depends on the data in his files and those data files will be changed after a user makes a change through my app.

I hope things are clear, and maybe this schema will help

---------------- | data|  
---------------- | base|-------------------

--------------------|----------------------

|---<----|>--->--|MyApp|<--->--|-<-->------|

|data----|data---|--data|-data---|------------|

U1----U2--------User3----------U4--------User5

PS: It's not a school project or something I'm doing this cause I like programming.

River
  • 8,585
  • 14
  • 54
  • 67
Amine boujida
  • 111
  • 1
  • 1
  • 6

1 Answers1

1

It's nice that you want to learn English and programming by yourself!

  • Firebase is the right choice, and you can find everything you need to know in the Firebase documentation. It is the best way to learn how to use it and I suggest you to read something about.

For your project I would suggest structuring your data this way, but it depends on what you want to do with them

{
    "mydatabase": {
        "users": {
            "mom": {
            },
            "dad": {
            }
        }
    }
}

If you provide any info about what you did or you want to achieve we'll be happy to help ;)

Devid Farinelli
  • 7,514
  • 9
  • 42
  • 73
  • Thank You Devid for the quick answer But where shoud i structure data like this which kind of file should I create to write this down , and for the project i didnt filled java classes yet its just graphics which are ready I should set the database then beggin filling activities , Wright now I'm trying to set as value for firebase an arraylist it will take the place of the files so each arraylist will be tied to a user I but I dont know if it will work., Thank you for help Devid :-) – Amine boujida Jul 05 '16 at 04:48
  • the arraylist is working but the way to structure data you've shwon me i think it's more efficient so please if it's possible to show me how to create a file and put data and structure into like this here's de requirements(The app is controlling the data and users are allowed to retreive data and also adding data ) and there's an other thing , when i'll publish my app in playstore for my family to download it surely it will need an internet connexion so if its possible to show me how to make the app connected to internet and the database ,thank you devid for Helping I Appreciate this =) – Amine boujida Jul 05 '16 at 05:19
  • Oh hahaha ther is another thing i saw in a firebase tuto that to be free to put and retreive data you should go to the file rules in firebase and change Write and Read from auth==!null to true but he also said that if we're doing production we should not do this caus everyone will have access to my database , so what should I do then ? – Amine boujida Jul 05 '16 at 05:23
  • Nice to hear that you are doing the tutorial. 1) About the security rules, production means when you officially release your app. During development is safe to have ".write":"true" and ".read":"true", but when you put your app on the play store you will have to change them 2) In firebase you don't have files, this is an example of what a Firebase database looks like https://dinosaur-facts.firebaseio.com/. This structure is called JSON https://en.wikipedia.org/wiki/JSON. Have you tried going to console.firebase.google.com > dashboard and creating/removing some data? – Devid Farinelli Jul 05 '16 at 05:42
  • If you understand how to work with JSON it will be easier to understand how to use Firebase from your app. 3) To connect your app to the database you just need to put the firebase sdk in your project. You can do it following these instructions: https://firebase.google.com/docs/android/setup#add_firebase_to_your_app I'm still here to help ;) – Devid Farinelli Jul 05 '16 at 05:48
  • Thank you devid for helping =) 1)about the security when i'll put my app on the play store and change the security settings the app still works correctly and users can retreive and exchange data with firebase? 2) I already created some data but from my app not directly in firebase website I created an arraylist and i'v put some data into it , I think I anderstood how it works i'll create a json file and put data into it then add it to firebase that's it? – Amine boujida Jul 05 '16 at 15:19
  • 3)I had already connected my app to my firebase I told you that i had set an arraylist of data from my app and i can see it appears in firebase (I was so happy haha) but the question is that when the app will be released the users need just to be connected to internet in order to exchange data with firebase and my app will do rest ? all i need is put internet permissions into manifest etc.. and my app will do the job or I should do something else to keep the users connected to the firebase to retreive and add data into it ? thank you Devid for Help =) Have a nice day – Amine boujida Jul 05 '16 at 15:22
  • { "users_info": [ { "pseudo": "Dad", "password": "something" } { "pseudo": "Mom", "password": "somehow" } { "pseudo": "Bro", "password": "sometime" } { "pseudo": "Sis", "password": "someday" } { "pseudo": "me", "password": "somewhere" }]} – Amine boujida Jul 05 '16 at 15:43
  • Is that a correct json file? can i put this file into firebase and use it? I saw this in a tutorial on youtube so i guess I'm having a arraylist called users_info but each index of the arraylist contains two things pseudo and password so should I create the objects pseudo and password? Thank you Devid for help =) – Amine boujida Jul 05 '16 at 15:45
  • I am busy, I'll reply as soon as I can ;) – Devid Farinelli Jul 06 '16 at 07:32
  • Ok no problem thank you a lot , I'm trying now to use json file but i didnt know how to add elements to a list and retreive data from it thank you again devid =) – Amine boujida Jul 06 '16 at 15:02
  • 1) Yes. If you write them good it works :) Security rules are used to prevent people from doing wrong thing. For example "only you can edit your profile" 2) Oh yes, that's good! 3) well done ahah! :D Yes! You only have to handle the case when there's no internet connection, for example showing a message: "no internet connection" – Devid Farinelli Jul 06 '16 at 18:54
  • It's not easy for me to help because I don't understand what do you mean for "json FILE". In json you have keys, values, objects and arrays. Try reading [this](http://code.tutsplus.com/tutorials/understanding-json--active-8817) the useful parts are Arrays, Objects and Nesting - Firebase is a BIG JSON object. - You are using a JSON array to store your users_info. NOTE1: you should use array if the order of the elements matter, if the order doesn't matter you can use json objects NOTE2: a json object is not like a Java object It's not easy to explain here, can we move in a chat? :D – Devid Farinelli Jul 06 '16 at 18:58