title: Error: com.google.firebase.database.DatabaseException: Can't convert object of type java.lang.String to type com.sam.simple.Project
body: <p>I was trying to store user information, for instance a NAME. But I got into some error. Searched and applied methods, but I got errors, logCat is posted below. Can I get a workaround please?</p>
  
  <p>I want to add a new root called "USERS" and user info under that, like a user profile.</p>
  
  <p>But now I just want to add Name of the user.</p>
  
  <p>Below are some codes...</p>
  
  <p>"MY CODE"</p>
  
  <pre><code>        firebaseAuth = FirebaseAuth.getInstance();
      firebaseDatabase = FirebaseDatabase.getInstance();
      databaseReference = firebaseDatabase.getReference();
  
      authStateListener = new FirebaseAuth.AuthStateListener() {
          @Override
          public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
              FirebaseUser user = firebaseAuth.getCurrentUser();
              if (user != null) {
  
                  Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid());
              } else {
  
                  Log.d(TAG, "onAuthStateChanged:signed_out");
              }
  
          }
      };
  
  
      databaseReference.addValueEventListener(new ValueEventListener() {
          @Override
          public void onDataChange(DataSnapshot dataSnapshot) {
  
              String value = dataSnapshot.getValue(String.class);
  
              Log.d(TAG, "Value is: " + value);
          }
  
          @Override
          public void onCancelled(DatabaseError error) {
  
              Log.w(TAG, "Failed to read value.", error.toException());
          }
      });
  
  
      btn_save_edit_profile.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              String user_name_string = user_name_edit.getText().toString();
  
              if (!user_name_string.equals("")){
                  FirebaseUser user = firebaseAuth.getCurrentUser();
                  String userID = user.getUid();
  
                  databaseReference.child(userID).child("Name").setValue(user_name_string);
                  Toast.makeText(ProfileEditActivity.this, "Saved Successfully!", Toast.LENGTH_SHORT).show();
  
  
  
              }
          }
      });
  </code></pre>
  
  <p>LOGCAT</p>
  
  <pre><code>Process: com.sam.simple, PID: 23912
  
                                         com.google.firebase.database.DatabaseException: Can't convert object of type java.lang.String to type com.sam.simple.Project
                                                                                      at com.google.android.gms.internal.adw.zzb(Unknown Source)
                                                                                      at com.google.android.gms.internal.adw.zza(Unknown Source)
                                                                                      at com.google.firebase.database.DataSnapshot.getValue(Unknown Source)
                                                                                      at com.sam.simple.FirebaseHelper.fetchData(FirebaseHelper.java:52)
                                                                                      at com.sam.simple.FirebaseHelper.access$000(FirebaseHelper.java:14)
                                                                                      at com.sam.simple.FirebaseHelper$1.onChildAdded(FirebaseHelper.java:65)
                                                                                      at com.google.android.gms.internal.uv.zza(Unknown Source)
                                                                                      at com.google.android.gms.internal.aaf.zzIo(Unknown Source)
                                                                                      at com.google.android.gms.internal.aal.run(Unknown Source)
                                                                                      at android.os.Handler.handleCallback(Handler.java:739)
                                                                                      at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                      at android.os.Looper.loop(Looper.java:145)
                                                                                      at android.app.ActivityThread.main(ActivityThread.java:6918)
                                                                                      at java.lang.reflect.Method.invoke(Native Method)
                                                                                      at java.lang.reflect.Method.invoke(Method.java:372)
                                                                                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
                                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
  </code></pre>
  
  <p>OUTPUT WANTED</p>
  
  <p><a href="https://i.stack.imgur.com/5ZTgV.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5ZTgV.jpg" alt="enter image description here"></a></p>
  
  <p>NOTE: IS IT BECAUSE MY "Project" root is causing any problem? Database maybe pointing towards main root and things? I am new to this. any help? thanks</p>
  
  <p>UPDATE #1: Added My Next Datasnapshot for Projects if this can help any further?</p>
  
  <pre><code>DatabaseReference db;
  Boolean saved = null;
  ArrayList&lt;Project&gt; projects=new ArrayList&lt;&gt;();
  
  public FirebaseHelper(DatabaseReference db) {
      this.db = db;
  }
  
  //WRITE IF NOT NULL
  public Boolean save(Project project)
  {
      if(project==null)
      {
          saved=false;
      }
      else
      {
          try
          {
              db.child("Project").push().setValue(project);
              saved=true;
  
          }catch (DatabaseException e)
          {
              e.printStackTrace();
              saved=false;
          }
      }
      return saved;
  }
  
  //IMPLEMENT FETCH DATA AND FILL ARRAYLIST
  private void fetchData(DataSnapshot dataSnapshot)
  {
      projects.clear();
      for (DataSnapshot ds : dataSnapshot.getChildren())
      {
          Project project = ds.getValue(Project.class);
         projects.add(project);
      }
  }
  
  //READ THEN RETURN ARRAYLIST
  public ArrayList&lt;Project&gt; retrieve() {
  
      /*Query queryreference = db.orderByChild("postedDate");*/
      /*Query lastToFirstQuery = db.orderByChild("postedDate");*/
  
      db.addChildEventListener(new ChildEventListener() {
          @Override
          public void onChildAdded(DataSnapshot dataSnapshot, String s) {
              fetchData(dataSnapshot);
  
          }
          @Override
          public void onChildChanged(DataSnapshot dataSnapshot, String s) {
              fetchData(dataSnapshot);
          }
          @Override
          public void onChildRemoved(DataSnapshot dataSnapshot) {
          }
          @Override
          public void onChildMoved(DataSnapshot dataSnapshot, String s) {
          }
          @Override
          public void onCancelled(DatabaseError databaseError) {
          }
      });
  
      return projects;
  </code></pre>