Limit the number of children added in firebase realtime database The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceHow to round a number to n decimal places in JavaShip an application with a databaseHow to store and view images on firebase?Get children using orderByChild-equalsTo in Firebase-AndroidAdding Social Media Share Logic From Firebase in AndroidWhat's the difference between Cloud Firestore and the Firebase Realtime Database?Updated global variables does not reflect inside ValueEventListener's onCancelled methodFirebase 'overrides nothing' after dependency updateHow to get the data saved in a USER_ID?Firebase Realtime database getvalue() not mapping the object

how can a perfect fourth interval be considered either consonant or dissonant?

Does Parliament hold absolute power in the UK?

Was credit for the black hole image misattributed?

How did the audience guess the pentatonic scale in Bobby McFerrin's presentation?

Is it ok to offer lower paid work as a trial period before negotiating for a full-time job?

Wall plug outlet change

Can withdrawing asylum be illegal?

What information about me do stores get via my credit card?

Netflix Recommendations?

Can a novice safely splice in wire to lengthen 5V charging cable?

Simulating Exploding Dice

Can a 1st-level character have an ability score above 18?

What do you call a plan that's an alternative plan in case your initial plan fails?

"... to apply for a visa" or "... and applied for a visa"?

Did the new image of black hole confirm the general theory of relativity?

The following signatures were invalid: EXPKEYSIG 1397BC53640DB551

Why does the Event Horizon Telescope (EHT) not include telescopes from Africa, Asia or Australia?

How to pronounce 1ターン?

Is it ethical to upload a automatically generated paper to a non peer-reviewed site as part of a larger research?

How do I add random spotting to the same face in cycles?

How many people can fit inside Mordenkainen's Magnificent Mansion?

How to remove this toilet supply line that seems to have no nut?

Is above average number of years spent on PhD considered a red flag in future academia or industry positions?

University's motivation for having tenure-track positions



Limit the number of children added in firebase realtime database



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experienceHow to round a number to n decimal places in JavaShip an application with a databaseHow to store and view images on firebase?Get children using orderByChild-equalsTo in Firebase-AndroidAdding Social Media Share Logic From Firebase in AndroidWhat's the difference between Cloud Firestore and the Firebase Realtime Database?Updated global variables does not reflect inside ValueEventListener's onCancelled methodFirebase 'overrides nothing' after dependency updateHow to get the data saved in a USER_ID?Firebase Realtime database getvalue() not mapping the object



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















enter image description here



How to limit the number of children added to 02 from firebase or java code in android.
I am going to add the child from the android application I made.
And I want to give a message to user if the number of children of 02 alreary 100.
I have tried



DatabaseReference dref=FirebaseDatabase.getInstance().getReference()
.child("Root").child("Time").child(2019).child(April).child(02);
dref.addValueEventListener(new ValueEventListener()
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot)
numberofpatients=dataSnapshot.getChildrenCount();

@Override
public void onCancelled(@NonNull DatabaseError databaseError)


);


does not work;



also tried



dref.addChildEventListener(new ChildEventListener() 
@Override
public void onChildAdded(@NonNull DataSnapshot dataSnapshot, @Nullable String s)
numberofpatients=dataSnapshot.getChildrenCount();


@Override
public void onChildChanged(@NonNull DataSnapshot dataSnapshot, @Nullable String s)
numberofpatients=dataSnapshot.getChildrenCount();


@Override
public void onChildRemoved(@NonNull DataSnapshot dataSnapshot)
numberofpatients=dataSnapshot.getChildrenCount();


@Override
public void onChildMoved(@NonNull DataSnapshot dataSnapshot, @Nullable String s)
numberofpatients=dataSnapshot.getChildrenCount();


@Override
public void onCancelled(@NonNull DatabaseError databaseError)


);


after getting the count i use the following to check the condition



 if(numberofpatients>=3)
android.support.v7.app.AlertDialog.Builder alert=
new android.support.v7.app.AlertDialog.Builder(
FillForm.this);
alert.setTitle("List Full");
alert.setMessage("Select another date!");
alert.setCancelable(false);
alert.setPositiveButton("Okay",
new DialogInterface.OnClickListener()
@Override
public void onClick(DialogInterface dialog, int which)
mDateSpinner.requestFocus();

);

alert.show();



Please Help, Only the idea needed.










share|improve this question
























  • I have got it. my problem was checking the condition outside the onDataChange method

    – Nongjaimayum Annas Khan
    Mar 24 at 10:11


















0















enter image description here



How to limit the number of children added to 02 from firebase or java code in android.
I am going to add the child from the android application I made.
And I want to give a message to user if the number of children of 02 alreary 100.
I have tried



DatabaseReference dref=FirebaseDatabase.getInstance().getReference()
.child("Root").child("Time").child(2019).child(April).child(02);
dref.addValueEventListener(new ValueEventListener()
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot)
numberofpatients=dataSnapshot.getChildrenCount();

@Override
public void onCancelled(@NonNull DatabaseError databaseError)


);


does not work;



also tried



dref.addChildEventListener(new ChildEventListener() 
@Override
public void onChildAdded(@NonNull DataSnapshot dataSnapshot, @Nullable String s)
numberofpatients=dataSnapshot.getChildrenCount();


@Override
public void onChildChanged(@NonNull DataSnapshot dataSnapshot, @Nullable String s)
numberofpatients=dataSnapshot.getChildrenCount();


@Override
public void onChildRemoved(@NonNull DataSnapshot dataSnapshot)
numberofpatients=dataSnapshot.getChildrenCount();


@Override
public void onChildMoved(@NonNull DataSnapshot dataSnapshot, @Nullable String s)
numberofpatients=dataSnapshot.getChildrenCount();


@Override
public void onCancelled(@NonNull DatabaseError databaseError)


);


after getting the count i use the following to check the condition



 if(numberofpatients>=3)
android.support.v7.app.AlertDialog.Builder alert=
new android.support.v7.app.AlertDialog.Builder(
FillForm.this);
alert.setTitle("List Full");
alert.setMessage("Select another date!");
alert.setCancelable(false);
alert.setPositiveButton("Okay",
new DialogInterface.OnClickListener()
@Override
public void onClick(DialogInterface dialog, int which)
mDateSpinner.requestFocus();

);

alert.show();



Please Help, Only the idea needed.










share|improve this question
























  • I have got it. my problem was checking the condition outside the onDataChange method

    – Nongjaimayum Annas Khan
    Mar 24 at 10:11














0












0








0








enter image description here



How to limit the number of children added to 02 from firebase or java code in android.
I am going to add the child from the android application I made.
And I want to give a message to user if the number of children of 02 alreary 100.
I have tried



DatabaseReference dref=FirebaseDatabase.getInstance().getReference()
.child("Root").child("Time").child(2019).child(April).child(02);
dref.addValueEventListener(new ValueEventListener()
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot)
numberofpatients=dataSnapshot.getChildrenCount();

@Override
public void onCancelled(@NonNull DatabaseError databaseError)


);


does not work;



also tried



dref.addChildEventListener(new ChildEventListener() 
@Override
public void onChildAdded(@NonNull DataSnapshot dataSnapshot, @Nullable String s)
numberofpatients=dataSnapshot.getChildrenCount();


@Override
public void onChildChanged(@NonNull DataSnapshot dataSnapshot, @Nullable String s)
numberofpatients=dataSnapshot.getChildrenCount();


@Override
public void onChildRemoved(@NonNull DataSnapshot dataSnapshot)
numberofpatients=dataSnapshot.getChildrenCount();


@Override
public void onChildMoved(@NonNull DataSnapshot dataSnapshot, @Nullable String s)
numberofpatients=dataSnapshot.getChildrenCount();


@Override
public void onCancelled(@NonNull DatabaseError databaseError)


);


after getting the count i use the following to check the condition



 if(numberofpatients>=3)
android.support.v7.app.AlertDialog.Builder alert=
new android.support.v7.app.AlertDialog.Builder(
FillForm.this);
alert.setTitle("List Full");
alert.setMessage("Select another date!");
alert.setCancelable(false);
alert.setPositiveButton("Okay",
new DialogInterface.OnClickListener()
@Override
public void onClick(DialogInterface dialog, int which)
mDateSpinner.requestFocus();

);

alert.show();



Please Help, Only the idea needed.










share|improve this question
















enter image description here



How to limit the number of children added to 02 from firebase or java code in android.
I am going to add the child from the android application I made.
And I want to give a message to user if the number of children of 02 alreary 100.
I have tried



DatabaseReference dref=FirebaseDatabase.getInstance().getReference()
.child("Root").child("Time").child(2019).child(April).child(02);
dref.addValueEventListener(new ValueEventListener()
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot)
numberofpatients=dataSnapshot.getChildrenCount();

@Override
public void onCancelled(@NonNull DatabaseError databaseError)


);


does not work;



also tried



dref.addChildEventListener(new ChildEventListener() 
@Override
public void onChildAdded(@NonNull DataSnapshot dataSnapshot, @Nullable String s)
numberofpatients=dataSnapshot.getChildrenCount();


@Override
public void onChildChanged(@NonNull DataSnapshot dataSnapshot, @Nullable String s)
numberofpatients=dataSnapshot.getChildrenCount();


@Override
public void onChildRemoved(@NonNull DataSnapshot dataSnapshot)
numberofpatients=dataSnapshot.getChildrenCount();


@Override
public void onChildMoved(@NonNull DataSnapshot dataSnapshot, @Nullable String s)
numberofpatients=dataSnapshot.getChildrenCount();


@Override
public void onCancelled(@NonNull DatabaseError databaseError)


);


after getting the count i use the following to check the condition



 if(numberofpatients>=3)
android.support.v7.app.AlertDialog.Builder alert=
new android.support.v7.app.AlertDialog.Builder(
FillForm.this);
alert.setTitle("List Full");
alert.setMessage("Select another date!");
alert.setCancelable(false);
alert.setPositiveButton("Okay",
new DialogInterface.OnClickListener()
@Override
public void onClick(DialogInterface dialog, int which)
mDateSpinner.requestFocus();

);

alert.show();



Please Help, Only the idea needed.







java android firebase firebase-realtime-database






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 23 at 20:38







Nongjaimayum Annas Khan

















asked Mar 22 at 6:37









Nongjaimayum Annas KhanNongjaimayum Annas Khan

166




166












  • I have got it. my problem was checking the condition outside the onDataChange method

    – Nongjaimayum Annas Khan
    Mar 24 at 10:11


















  • I have got it. my problem was checking the condition outside the onDataChange method

    – Nongjaimayum Annas Khan
    Mar 24 at 10:11

















I have got it. my problem was checking the condition outside the onDataChange method

– Nongjaimayum Annas Khan
Mar 24 at 10:11






I have got it. my problem was checking the condition outside the onDataChange method

– Nongjaimayum Annas Khan
Mar 24 at 10:11













1 Answer
1






active

oldest

votes


















0














You have to loop through and get the number of children in child("02")



example



FirebaseDatabase.getInstance().getReference().child("Time/2019/April/02").addValueEventListener(new ValueEventListener() 
@Override
public void onDataChange(DataSnapshot dataSnapshot)
if (dataSnapshot.getChildrenCount()==100)

//code here




@Override
public void onCancelled(DatabaseError databaseError)


);





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55294139%2flimit-the-number-of-children-added-in-firebase-realtime-database%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You have to loop through and get the number of children in child("02")



    example



    FirebaseDatabase.getInstance().getReference().child("Time/2019/April/02").addValueEventListener(new ValueEventListener() 
    @Override
    public void onDataChange(DataSnapshot dataSnapshot)
    if (dataSnapshot.getChildrenCount()==100)

    //code here




    @Override
    public void onCancelled(DatabaseError databaseError)


    );





    share|improve this answer



























      0














      You have to loop through and get the number of children in child("02")



      example



      FirebaseDatabase.getInstance().getReference().child("Time/2019/April/02").addValueEventListener(new ValueEventListener() 
      @Override
      public void onDataChange(DataSnapshot dataSnapshot)
      if (dataSnapshot.getChildrenCount()==100)

      //code here




      @Override
      public void onCancelled(DatabaseError databaseError)


      );





      share|improve this answer

























        0












        0








        0







        You have to loop through and get the number of children in child("02")



        example



        FirebaseDatabase.getInstance().getReference().child("Time/2019/April/02").addValueEventListener(new ValueEventListener() 
        @Override
        public void onDataChange(DataSnapshot dataSnapshot)
        if (dataSnapshot.getChildrenCount()==100)

        //code here




        @Override
        public void onCancelled(DatabaseError databaseError)


        );





        share|improve this answer













        You have to loop through and get the number of children in child("02")



        example



        FirebaseDatabase.getInstance().getReference().child("Time/2019/April/02").addValueEventListener(new ValueEventListener() 
        @Override
        public void onDataChange(DataSnapshot dataSnapshot)
        if (dataSnapshot.getChildrenCount()==100)

        //code here




        @Override
        public void onCancelled(DatabaseError databaseError)


        );






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 22 at 7:08









        DERRICK NGATIADERRICK NGATIA

        3913




        3913





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55294139%2flimit-the-number-of-children-added-in-firebase-realtime-database%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript