title: Issues handling numbers and floating point numbers with firebase database and firebaseui
body: <p>Note added 15 March 2017:</p>
  
  <p>With my increasing experience on Firebase database, I realized to be very careful when using quotes or not on data values. </p>
  
  <p>Example: When I edit data manually in the console and want to set it to the boolean value of TRUE, it is very important to write it without quotes and lower case. Without quotes Firebase detect the right datatype and converts them correctly to a boolean value of true. If it has quotes like "true", it is interpreted as a string and thus I get exception reading could not convert string to boolean.
  I also realized, if the value is not all lower case, Firebase console automatically converts them to a string and add quotes around it.</p>
  
  <p>The same goes for number values, list them without quotes or the conversion will fail.</p>
  
  <p>I did not found this clearly documented elsewhere.
  This at least applies to the Android version of Firebase database.</p>
  
  <p>Original question:</p>
  
  <p>up to now i thought, all content in the firebase database is held as strings.</p>
  
  <p>But whenever i accessed a specific part of my data, i got the following error:</p>
  
  <pre><code>com.google.firebase.database.DatabaseException: Failed to convert value of type java.lang.Double to String
                        at com.google.android.gms.internal.zzanp.zzcf(Unknown Source)
                        at com.google.android.gms.internal.zzanp.zzb(Unknown Source)
                        at com.google.android.gms.internal.zzanp.zza(Unknown Source)
                        at com.google.android.gms.internal.zzanp.zzb(Unknown Source)
                        at com.google.android.gms.internal.zzanp$zza.zze(Unknown Source)
                        at com.google.android.gms.internal.zzanp$zza.zzcg(Unknown Source)
                        at com.google.android.gms.internal.zzanp.zze(Unknown Source)
                        at com.google.android.gms.internal.zzanp.zzb(Unknown Source)
                        at com.google.android.gms.internal.zzanp.zza(Unknown Source)
                        at com.google.firebase.database.DataSnapshot.getValue(Unknown Source)
                        at com.firebase.ui.database.FirebaseListAdapter.parseSnapshot(FirebaseListAdapter.java:120)
                        at com.firebase.ui.database.FirebaseListAdapter.getItem(FirebaseListAdapter.java:109)
                        at com.firebase.ui.database.FirebaseListAdapter.getView(FirebaseListAdapter.java:137)
                        at android.widget.AbsListView.obtainView(AbsListView.java:2346)
                        at android.widget.ListView.measureHeightOfChildren(ListView.java:1280)
                        at android.widget.ListView.onMeasure(ListView.java:1188)
                        at android.view.View.measure(View.java:18788)
                        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
                        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
                        at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
                        at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
                        at android.view.View.measure(View.java:18788)
                        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
                        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
                        at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
                        at android.view.View.measure(View.java:18788)
                        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
                        at android.support.v7.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:391)
                        at android.view.View.measure(View.java:18788)
                        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
                        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
                        at android.view.View.measure(View.java:18788)
                        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
                        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
                        at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
                        at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
                        at android.view.View.measure(View.java:18788)
                        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
                        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
                        at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2643)
                        at android.view.View.measure(View.java:18788)
                        at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2100)
                        at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1216)
                        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1452)
                        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
                        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
                        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
                        at android.view.Choreographer.doCallbacks(Choreographer.java:670)
                        at android.view.Choreographer.doFrame(Choreographer.java:606)
                        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
                        at android.os.Handler.handleCallback(Handler.java:739)
                        at android.os.Handler.dispatchMessage(Handler.java:95)
                        at android.os.Looper.loop(Looper.java:148)
                        at android.app.ActivityThread.main(ActivityThread.java:5417)
                        at java.lang.reflect.Method.invoke(Native Method)
                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
  </code></pre>
  
  <p>As i did not handle with Double values (yet), i was very confused.</p>
  
  <p>In my database, i store the weight of a car, and  a full entry looks like this:</p>
  
  <pre><code>{
    "manualCarID-1" : {
      "created" : "Firebase.ServerValue.TIMESTAMP",
      "description" : "MAN TGX 4x2 mit Flachbett",
      "emptyWeight" : "8.3x",
      "ownerUserID" : "manualUser1",
      "pictureFile" : "none"
    },
    "manualCarID-2" : {
      "created" : "today",
      "description" : "MB SK",
      "emptyWeight" : "5.6x",
      "ownerUserID" : "maualUser1",
      "pictureFile" : "none"
    },
    "manualCarID-3" : {
      "created" : "today",
      "description" : "Radlader",
      "emptyWeight" : "5.6x",
      "ownerUserID" : "maualUser1",
      "pictureFile" : "none"
    }
  }
  </code></pre>
  
  <p>In my program i created a class representing this structure</p>
  
  <pre><code>public class CarsDbItem {
      String created;
      String description;
      String emptyWeight;
      String ownerUserID;
      String pictureFile;
  
      //... Stripped out the getters and setters here
  }
  </code></pre>
  
  <p>I use this class to get my data with the FireBaseListAdapter</p>
  
  <pre><code>FirebaseListAdapter&lt;helpers.CarsDbItem&gt; adapter = new FirebaseListAdapter&lt;helpers.CarsDbItem&gt;(this,
          CarsDbItem.class,
          R.layout.item_car_select,
          helpers.MyDatabaseUtil.getCarsDbReference()) {
      protected void populateView(View view, helpers.CarsDbItem carItem, int position) {
          DatabaseReference itemRef = getRef(position);
  
          final String itemKey = itemRef.getKey();
          final String pictureFile = carItem.getPictureFile();
          final String emptyWeight = carItem.getEmptyWeight();
          final String owner = carItem.getOwnerUserID();
          final String description = carItem.getDescription();
          final View itemView = view;
  
          ((TextView) itemView.findViewById(R.id.textViewItemCarDescription)).setText(description);
          ((TextView) itemView.findViewById(R.id.textViewItemCarOwner)).setText(owner);
          ((TextView) itemView.findViewById(R.id.textViewItemCarEmptyWeight)).setText(emptyWeight);
          ((ImageView) itemView.findViewById(R.id.imageCar)).setImageResource(R.drawable.ic_launcher);
          itemView.setTag(itemKey);
      }
  };
  </code></pre>
  
  <p>Now i found out, that the problem is the emptyweight being a "number only". If i add a "x" at the end of my data in the database for "emptyWeight", all works fine.</p>
  
  <p>So i am a bit confused.
  Why is the my "string" data in the Firebase database converted into a matching "variable type", i did not found a hint about this.</p>
  
  <p>Thanks
  Juergen</p>
  
  <p>Notes:
  My confusion was, that the firebase console put my numbers sometimes in "", so i thought it had to be.
  The difference is if a value is noted as
  5.6 => number
  or
  "5.6" => string</p>
  
  <p>after getting this fixed in all places, i changed my classes to held float or dubles for my numbers and all was fine</p>
  
  <p>thanks
  Juergen</p>