title: Firebase setPersistenceEnabled(true) and keepSynced(true) casues some issues
body: <p>I want to keep data offline and work with it, when the network is available data should be synced to all instances, I've</p>
  
  <pre><code>public class MyApp extends Application {      
  
      @Override
      public void onCreate() {
          super.onCreate();
          FirebaseDatabase.getInstance().setPersistenceEnabled(true);
      }
  }
  </code></pre>
  
  <p>in MainActivity I've </p>
  
  <pre><code>    @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
  
          mDatabaseReference = FirebaseUtils.getAllPostsDatabaseReference();
          mDatabaseReference.keepSynced(true);
      }
  </code></pre>
  
  <p>there comes a issue that is same data is shown multiple times when ever a new child is added, to avoid that I added a trick as you see in child listener as </p>
  
  <pre><code>@Override
  public void onResume() {
      super.onResume();
  
      cleanUp();
  
      mChildEventListener = new ChildEventListener() {
          @Override
          public void onChildAdded(DataSnapshot dataSnapshot, String s) {
  
              try{
                  if (dataSnapshot.exists() &amp;&amp; dataSnapshot.hasChildren() &amp;&amp; !dataSnapshot.equals(null)){
                      MyObject mo =  dataSnapshot.getValue(MyObject.class);
                      mList.add(mo);
                      mAdapter.notifyDataSetChanged();
  
                  } else {
                      ///
                  }
              } catch (Exception e){
                  e.printStackTrace();
              }
          }
  
          // omitting @Override methods 
  
      };
  
      mQuery = getQuery();
      mQuery.addChildEventListener(mChildEventListener);
  
      mAdapter = new MyAdapter((AppCompatActivity)getContext(), mList);
      mRecyclerView.setAdapter(mAdapter);
  } 
  </code></pre>
  
  <p>When ever activity is Resumed I call cleanUp() which is </p>
  
  <pre><code>private void cleanUp(){
      try {
          if (mAdapter != null &amp;&amp; mList.size() &gt; 0){
              mAdapter.clear();
              mList.clear();
              Log.e("ADAPTER", "Cleared");
          }
      } catch (Exception e){
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>this point App is Resumed it works correct and there is no any data duplication, but when ever app is running on on device and data is added to child it duplicates the instances of the newly added data as may times as there are devices using the app (i.e if there are 10 active devices currently using the App then newly added is shown duplicated 1,2,3,4,5,6,7,8,9 times per device respectively isn't that weird behavior?)</p>
  
  <p>OK I tried to make a change like this add cleanUp(); in onChildAdded()</p>
  
  <pre><code>mChildEventListener = new ChildEventListener() {
              @Override
              public void onChildAdded(DataSnapshot dataSnapshot, String s) {
                  cleanUp();// Added here to avoid data duplication
                  try{
                      if (dataSnapshot.exists() &amp;&amp; dataSnapshot.hasChildren() &amp;&amp; !dataSnapshot.equals(null)){
                          MyObject mo =  dataSnapshot.getValue(MyObject.class);
                          mList.add(mo);
                          mAdapter.notifyDataSetChanged();
  
                      } else {
                          ///
                      }
                  } catch (Exception e){
                      e.printStackTrace();
                  }
              }
  
              // omitting @Override methods 
  
          };
  </code></pre>
  
  <p>at this point the duplication is not happening but only new added data is shown and all other childs are cleared.</p>