title: Android Firebase app crashes after updating ArrayAdapter
body: <p>Hello I am currently working on my very first android app and I have came across and issue where the Application crashes after I add an item into the database and attempt to display the additional item to the UI. 
  I am using Firebase and a custom <code>ArrayAdapter</code> to display the database.
  The issue only happens when I add a new item to the database and call updateUI().
  The issue isn't in <code>updateUI()</code>, I know this because I call <code>updateUI()</code> in onCreate, and the database information is pulled successfully. Also if I use a traditional ArrayAdapter the process works. I was hoping to receive some help and understand why this problem is occurring.</p>
  
  <p>Here is </p>
  
  <blockquote>
    <p>User.java</p>
  </blockquote>
  
  <pre><code>public void setUserInformation(String task){
      String removeFirstLast = task.substring(1, task.length()-1);
      String[] array = removeFirstLast.split(",");
      dueDate = array[0].substring(9, array[0].length());
      taskName = array[1].substring(11, array[1].length());
      courseName = array[2].substring(13, array[2].length());
  }
  </code></pre>
  
  <blockquote>
    <p>UserAdapter.java</p>
  </blockquote>
  
  <pre><code>public class UserAdapter extends ArrayAdapter&lt;User&gt;{
  
  private final Context context;
  private final ArrayList&lt;User&gt; data;
  private final int layoutResourceId;
  public UserAdapter(Context context, int layoutResourceId, ArrayList&lt;User&gt; data) {
      super(context, layoutResourceId, data);
      this.context = context;
      this.data = data;
      this.layoutResourceId = layoutResourceId;
  }
  
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
      View row = convertView;
      ViewHolder holder = null;
      if(row == null)
      {
          LayoutInflater inflater = ((Activity)context).getLayoutInflater();
          row = inflater.inflate(layoutResourceId, parent, false);
  
          holder = new ViewHolder();
          holder.textView1 = (TextView)row.findViewById(R.id.task_title);
          holder.textView2 = (TextView)row.findViewById(R.id.due_date);
  
          row.setTag(holder);
      }
      else
      {
          holder = (ViewHolder)row.getTag();
      }
  
      User user = data.get(position);
  
      holder.textView1.setText(user.getTaskName());
      holder.textView2.setText(user.getDueDate() + "-  " + user.getCourseName());
  
  
      return row;
  }
  
  static class ViewHolder{
      TextView textView1;
      TextView textView2;
  }
  </code></pre>
  
  <p>updateUI() in list_activity.java
  There was an issue where the only taskName was being pulled successfully from the database. Was receiving <code>NullPointerException</code> on courseName, dueDate.</p>
  
  <pre><code>private void updateUI(){
      final ArrayList&lt;User&gt; userList = new ArrayList&lt;&gt;();
      //final ArrayList&lt;String&gt; taskList = new ArrayList&lt;&gt;();
  
      //pull from database
      Query query = myRef.child("Users").child(user_id).child("TO DO");
      query.addValueEventListener(new ValueEventListener() {
          @Override
          public void onDataChange(DataSnapshot dataSnapshot) {
              for(DataSnapshot ds: dataSnapshot.getChildren()) {
                  //    courseName = ds.child("Course Name").getValue().toString();
                  //    taskName = ds.child("Task Name").getValue().toString();
                  //    dueDate = ds.child("Due Date").getValue().toString();
                  String task = ds.getValue().toString();
                  //taskList.add(taskName);
                  user = new User();
                  userList.add(user);
                  user.setUserInformation(task);
                  //   user.setCourseName(courseName);
                  //    user.setDueDate(dueDate);
                  //   user.setTaskName(taskName);
  
  
  
                  //    Log.i("AlertDialog","Due Date Entered "+ dueDate);
                  //    Log.i("AlertDialog","Course Name Entered "+ courseName);
                  //    Log.i("AlertDialog","Task Name Entered "+ taskName);
                  Log.i("AlertDialog","Task Entered "+ task);
              }
          }
  
          @Override
          public void onCancelled(DatabaseError databaseError) {
  
          }
      });
  
      if (mAdapter == null) {
       //    mAdapter = new ArrayAdapter&lt;&gt;(this,
        //   R.layout.list_item,
        //   R.id.task_title,
       //    taskList);
        //   mTaskListView.setAdapter(mAdapter);
          mAdapter = new UserAdapter(this,R.layout.list_item, userList);
          mTaskListView.setAdapter(mAdapter);
  
      } else {
          mAdapter.clear();
          mAdapter.addAll(userList);
          mAdapter.notifyDataSetChanged();
      }
  
  }
  </code></pre>
  
  <p>To summarize even with the error, data is still added to the database, <code>updateUI()</code> successfully pulls database information, the application closes after calling <code>updateUI()</code> again once the user has uploaded new info to the database. The issue does not occur when a traditional <code>ArrayAdapter</code> is used. </p>
  
  <p>I receive an array out of bounds error, even though I know this is not the issue.</p>
  
  <pre><code>11-21 23:38:31.883 9431-9431/com.example.android.procastinator E/AndroidRuntime: FATAL EXCEPTION: main
                                                                               Process: com.example.android.procastinator, PID: 9431
                                                                               java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
                                                                                   at com.example.android.procastinator.User.setUserInformation(User.java:61)
                                                                                   at com.example.android.procastinator.list_Activity$2.onDataChange(list_Activity.java:158)
                                                                                   at com.google.android.gms.internal.zzbmz.zza(Unknown Source)
                                                                                   at com.google.android.gms.internal.zzbnz.zzYj(Unknown Source)
                                                                                   at com.google.android.gms.internal.zzboc$1.run(Unknown Source)
                                                                                   at android.os.Handler.handleCallback(Handler.java:751)
                                                                                   at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                   at android.os.Looper.loop(Looper.java:154)
                                                                                   at android.app.ActivityThread.main(ActivityThread.java:6119)
                                                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
  </code></pre>
  
  <p>Here is an example of what String task is equal to </p>
  
  <pre><code>{Due Date=11/25/17, Task Name=HW 6, Course Name=CSC 4360}
  </code></pre>