title: Passing Json data according to the json file Id in a RecyclerView
body: <p>I have a problem and I've tried many times and I didn't succeed please want you to help me! I have a RecyclerView where I'm getting data from json files. I have two jsons file and my json files looks like that:</p>
  
  <pre><code>{ "ussd_code":[
  {"cmd_id": 1,"cmd_name": "Solde de crédit","cmd_instruction": "*100#","cmd_commentaire": null,"opetor_id": 2,"mnu_id": 12,"test":2},
  {"cmd_id": 2,"cmd_name": "Solde de crédit","cmd_instruction": "*565#","cmd_commentaire": null,"opetor_id": 1,"mnu_id": 12,"test":1},
  {"cmd_id": 3,"cmd_name": "Solde de crédit","cmd_instruction": "*124#","cmd_commentaire": null,"opetor_id": 3,"mnu_id": 12,"test":3},
  {"cmd_id": 4,"cmd_name": "Airtel Money","cmd_instruction": "*501#","cmd_commentaire": null,"opetor_id": 1,"mnu_id": 12,"test":1},
  {"cmd_id": 5,"cmd_name": "Mon numéro","cmd_instruction": "*502#","cmd_commentaire": null,"opetor_id": 1,"mnu_id": 12,"test":1},
  {"cmd_id": 6,"cmd_name": "8 minutes (Vers airtel)","cmd_instruction": "*171*50#", "cmd_commentaire": "50 Unités pour 1 jour","opetor_id": 1,"mnu_id": 11,"test":1},
  {"cmd_id": 7,"cmd_name": "10 min (Tous réseau)","cmd_instruction": "*171*0100#","cmd_commentaire": "100 Unités pour 1 jour","opetor_id": 1,"mnu_id": 11,"test":1}]}
  </code></pre>
  
  <p>and another:</p>
  
  <pre><code>{"operator":[
  {"opetor_id": 1,"opetor_name": "Airtel","ctry_id": "CD"},
  {"opetor_id": 2,"opetor_name": "Vodacom","ctry_id": "CD"},
  {"opetor_id": 3,"opetor_name": "Orange","ctry_id": "CD"},
  {"opetor_id": 4,"opetor_name": "Tigo","ctry_id": "CD"}]}
  </code></pre>
  
  <p>I'm passing the data in RecyclerView once I verify that the <code>operator_id</code> from my two json file are the same this is my codes: </p>
  
  <pre class="lang-java prettyprint-override"><code>String cmd_id = new String();
  String cmd_name = new String();
  String cmd_instruction = new String();
  String cmd_commentaire = new String();
  ...
  for (int z = 0; z &lt; jArrayMenu.length(); z++)
  {
      JSONObject MnuDetail = jArrayMenu.getJSONObject(z);
      Integer operatorIdMenu = MnuDetail.getInt("opetor_id");
      //cmd_operator_test.add(MnuDetail.getInt("opetor_id"));
      if (OperaID.equals(operatorIdMenu))
      {
          cmd_id=(MnuDetail.getString("cmd_id"));
          cmd_name=(MnuDetail.getString("cmd_name"));
          cmd_instruction=(MnuDetail.getString("cmd_instruction"));
          cmd_commentaire=(MnuDetail.getString("cmd_commentaire"));
          CustomAdapter customAdapter = new CustomAdapter(MainActivity.this, cmd_id, cmd_name, cmd_instruction, cmd_commentaire);
          //set the Adapter to RecyclerView
          rv.setAdapter(customAdapter);
      }
  }
  </code></pre>
  
  <p>here is my adapter:</p>
  
  <pre class="lang-java prettyprint-override"><code>public class CustomAdapter extends RecyclerView.Adapter&lt;CustomAdapter.MyViewHolder&gt; {
  
      String cmd_id = new String();
      String cmd_name = new String();
      String cmd_instruction = new String();
      String cmd_commentaire = new String();
      ArrayList&lt;String&gt; cmd_operator = new ArrayList&lt;&gt;();
  
      Context context;
  
      public CustomAdapter(Context context, String cmd_id, String cmd_name, String cmd_instruction, String cmd_commentaire) {
          this.context = context;
          this.cmd_id = cmd_id;
          this.cmd_name = cmd_name;
          this.cmd_instruction = cmd_instruction;
          this.cmd_commentaire = cmd_commentaire;
      }
  
      @Override
      public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          // inflate the item Layout
          View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.rowlayout, parent, false);
          MyViewHolder vh = new MyViewHolder(v); // pass the view to View Holder
          return vh;
      }
  
      @Override
      public void onBindViewHolder(MyViewHolder holder, final int position) {
          // set the data in items
          //holder.name.setText(cmd_id.get(position));
          holder.email.setText(cmd_name);
          //holder.mobileNo.setText(cmd_instruction.get(position));
          // implement setOnClickListener event on item view.
          holder.itemView.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  // display a toast with person name on item click
                  //Toast.makeText(context, cmd_name.get(position), Toast.LENGTH_SHORT).show();
                  if (ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED){
                      Toast.makeText(MainActivity.this, "Please grant the permission to call", Toast.LENGTH_SHORT).show();
                      requestPermissions();
                  }else {
                      //Toast.makeText(orange.this, "Recycler View Item: " + i, Toast.LENGTH_LONG).show();
                      //final Intent myIntent;
                      Intent myIntent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + cmd_instruction.replace("#","") + Uri.encode("#")));
                      startActivity(myIntent);
                  }
              }
          });
      }
  
      @Override
      public int getItemCount() {
          return cmd_id.length();
      }
  
      public class MyViewHolder extends RecyclerView.ViewHolder {
          TextView name, email, mobileNo;// init the item view's
  
          public MyViewHolder(View itemView) {
              super(itemView);
  
              // get the reference of item view's
              name = (TextView) itemView.findViewById(R.id.name);
              email = (TextView) itemView.findViewById(R.id.email);
              mobileNo = (TextView) itemView.findViewById(R.id.mobileNo);
          }
      }
  }
  </code></pre>
  
  <p>when i run my app the place where the <code>opetor_id</code> equal 1 in the <code>ussd_code</code> json file it gives me only the last value orthers wise I have five <code>opetor_id</code> but still having the last value. Dont know why orthers are not appears.</p>