title: Parse JSON data from assets folder in Recyclerview
body: <p>In my app I have stored a JSON file in asset folder. Now I am trying to parse a local JSON file to show some imformation in the recyclerview. My Json file look like this. </p>
  
  <pre><code>     {
       "contacts":[
        {
          "_id": "57f762f1",
          "dn": "CNdreas ",
          "mobile": "123456",
          "mail": "and@yahoo.com",
          "name": "Hallo",
          "company": "xyz company",
          "department": "software",
          "title": "Junior Developer",
          "__v": 0,
          "updated_at": "2016-10-07T08:55:13.909Z"
        },
        {
          "_id": "57f7",
          "dn": "CNernard",
          "mobile": "1239855",
          "mail": "mail@yahoo.com",
          "name": "nameis",
          "company": "xyz Company",
          "department": "Inhouse",
          "__v": 0,
          "updated_at": "2016"
        },
       ..................lots of object
  </code></pre>
  
  <p>From this file I want to get mobile, mail,name, company, department and title. but in some object "title" is not included. In my example it is shown. I try to parse these information in recyclerview and cardview. But each time my app is crashing. I am not getting how can I parse some datas from this JSON and show on RecyclerView. Here is my Model Class for JSON Data</p>
  
  <pre><code>public class MyColleageModel {
  private String _id;
  private String dn;
  private String mobile;
  private String mail;
  private String name ;
  private String company ;
  private String department;
  private String title ;
  private int __v ;
  private String updated_at;
  
  public MyColleageModel() {
  
  }
  
  public MyColleageModel(String mobile, String mail,
                         String name, String company,
                         String department, String title) {
  
      this.mobile = mobile;
      this.mail = mail;
      this.name = name;
      this.company = company;
      this.department = department;
      this.title = title;
    }
  
  public String get_id() {
      return _id;
  }
  
  public String getDn() {
      return dn;
  }
  
  public String getMobile() {
      return mobile;
  }
  
  public String getMail() {
      return mail;
  }
  
  public String getName() {
      return name;
  }
  
  public String getCompany() {
      return company;
  }
  
  public String getDepartment() {
      return department;
  }
  
  public String getTitle() {
      return title;
  }
  
  public int get__v() {
      return __v;
  }
  
  public String getUpdated_at() {
      return updated_at;
  }
  }
  </code></pre>
  
  <p>My MainActivity is </p>
  
  <pre><code>public class MyColleaguesPage extends AppCompatActivity {
  
  private RecyclerView recyclerView;
  private RecyclerView.Adapter adapter;
  private List&lt;MyColleageModel&gt; colleagueObject;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.mycolleagues_layout);
      recyclerView=(RecyclerView)findViewById(R.id.colleagues_recycler);
      recyclerView.setHasFixedSize(true);
      RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
      recyclerView.setLayoutManager(layoutManager);
  
      colleagueObject = new ArrayList&lt;&gt;();
      try {
          JSONObject obj = new JSONObject(loadJSONFromAsset());
          JSONArray m_jArry = obj.getJSONArray("contacts");
          ArrayList&lt;HashMap&lt;String, String&gt;&gt; formList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
          HashMap&lt;String, String&gt; m_li;
  
          for (int i = 0; i &lt; m_jArry.length(); i++) {
              JSONObject jo_inside = m_jArry.getJSONObject(i);
              String val1 = jo_inside.getString("mobile");
              String val2 = jo_inside.getString("mail");
              String val3 = jo_inside.getString("name");
              String val4 = jo_inside.getString("company");
              String val5 = jo_inside.getString("department");
              String val6 = jo_inside.optString("title");
  
              //Add your values in your `ArrayList` as below:
              m_li = new HashMap&lt;String, String&gt;();
              m_li.put("mobile", val1);
              m_li.put("mail",val2);
              m_li.put("name", val3);
              m_li.put("company",val4);
              m_li.put("department", val5);
              m_li.put("title",val6);
  
              formList.add(m_li);
          }
      } catch (JSONException e) {
          e.printStackTrace();
      }
      recyclerViewstart();
      loadJSONFromAsset();
      adapter = new MyColleaguesAdapter(colleagueObject,this);
      recyclerView.setAdapter(adapter);
  }
  private String loadJSONFromAsset() {
      String json = null;
      try {
  
          InputStream is = getAssets().open("colleagues.json");
  
          int size = is.available();
  
          byte[] buffer = new byte[size];
  
          is.read(buffer);
  
          is.close();
  
          json = new String(buffer, "UTF-8");
  
  
      } catch (IOException ex) {
          ex.printStackTrace();
          return null;
      }
      return json;
  
  
  }
  
  }
  </code></pre>
  
  <p>I am getting null pointer exception error here is my error log. I know in some case title is not included. But how can I get all my data to show in recyclerview without any error?</p>
  
  <pre><code>  07-15 10:51:05.927 2406-2406/? W/art: Before Android 4.1, method int 
    android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int, 
     boolean) would have incorrectly overridden the package-private method in 
     android.widget.ListView
    07-15 10:51:08.049 2406-2406/com.testgrid W/System.err: 
    org.json.JSONException: No value for title
    07-15 10:51:08.049 2406-2406/com.testgrid W/System.err:     at 
    org.json.JSONObject.get(JSONObject.java:389)
    07-15 10:51:08.049 2406-2406/com.testgrid W/System.err:     at 
    org.json.JSONObject.getString(JSONObject.java:550)
    07-15 10:51:08.049 2406-2406/com.testgrid W/System.err:     at 
    myColleagues.MyColleaguesPage.onCreate(MyColleaguesPage.java:55)
    07-15 10:51:08.049 2406-2406/com.testgrid W/System.err:     at 
    android.app.Activity.performCreate(Activity.java:6662)
    07-15 10:51:08.049 2406-2406/com.testgrid W/System.err:     at 
  
   android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
    07-15 10:51:08.049 2406-2406/com.testgrid W/System.err:     at 
   android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
   07-15 10:51:08.049 2406-2406/com.testgrid W/System.err:     at 
   android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
   07-15 10:51:08.049 2406-2406/com.testgrid W/System.err:     at 
   android.app.ActivityThread.-wrap12(ActivityThread.java)
   07-15 10:51:08.049 2406-2406/com.testgrid W/System.err:     at 
   android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
   07-15 10:51:08.049 2406-2406/com.testgrid W/System.err:     at 
   android.os.Handler.dispatchMessage(Handler.java:102)
   07-15 10:51:08.049 2406-2406/com.testgrid W/System.err:     at 
   android.os.Looper.loop(Looper.java:154)
   07-15 10:51:08.049 2406-2406/com.testgrid W/System.err:     at 
   android.app.ActivityThread.main(ActivityThread.java:6077)
   07-15 10:51:08.049 2406-2406/com.testgrid W/System.err:     at 
   java.lang.reflect.Method.invoke(Native Method)
   07-15 10:51:08.049 2406-2406/com.testgrid W/System.err:     at 
  </code></pre>