title: Data Passing Issue adapter to fragment in android (The default value <null> was returned)
body: <p>I was trying to pass some data through an <strong>intent and bundle</strong> from one activity ** (actually it is Adapter of the activity) ** to fragment. All the string values passing without any issue to the fragment, <strong>but integer and double values are passed as null.</strong></p>
  
  <p><strong>It shows this warning :</strong> </p>
  
  <blockquote>
    <p>Key invoiceId expected String but value was a java.lang.Integer.  The
    default value  was returned</p>
    
    <p>Attempt to cast generated internal exception:</p>
    
    <p>java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String</p>
  </blockquote>
  
  <p><strong>The codes are as follows:</strong></p>
  
  <pre><code>Intent intent = new Intent(mContext, SalesViewActivity.class);
  
                  intent.putExtra(SalesViewFragment.ARG_INVOICE_ID, sales.get(position).getInvoiceInvoiceId());
                  intent.putExtra(SalesViewFragment.ARG_INVOICE_CODE, sales.get(position).getInvoiceInvoiceCode());
                  intent.putExtra(SalesViewFragment.ARG_CUSTOMER_ID, sales.get(position).getInvoiceCustomerId());
                  intent.putExtra(SalesViewFragment.ARG_INVOICE_ORDER_ID, sales.get(position).getInvoiceOrderId());
  
                  intent.putExtra(SalesViewFragment.ARG_SALES_PERSON, sales.get(position).getInvoiceSalesPerson());
                  intent.putExtra(SalesViewFragment.ARG_INVOICE_CUSTOMER_NAME, sales.get(position).getCustomerCustomerName());
  
                  intent.putExtra(SalesViewFragment.ARG_INVOICE_TOTAL, sales.get(position).getInvoiceTotalAmount());
                  intent.putExtra(SalesViewFragment.ARG_START_TIME, sales.get(position).getInvoiceStartTimestamp());
  
                  intent.putExtra(SalesViewFragment.ARG_INVOICE_DISCOUNT, sales.get(position).getInvoiceDiscountTotal());
                  intent.putExtra(SalesViewFragment.ARG_INVOICE_CASH_DISCOUNT, sales.get(position).getInvoiceCashDiscount());
                  intent.putExtra(SalesViewFragment.ARG_INVOICE_DISCOUNT_TRADE, sales.get(position).getInvoiceDiscountTrade());
                  intent.putExtra(SalesViewFragment.ARG_INVOICE_DISCOUNT_PARENTAGE, sales.get(position).getInvoiceDiscountParentage());
  
                  intent.putExtra(SalesViewFragment.ARG_INVOICE_STATUS, sales.get(position).getInvoiceStatus());
                  intent.putExtra(SalesViewFragment.ARG_INVOICE_REMARKS, sales.get(position).getInvoiceRemarks());
  
                  mContext.startActivity(intent);
  </code></pre>
  
  <p>Here is SalesViewActivity.java <strong>(I think the problem occurs here)</strong></p>
  
  <pre><code>Fragment mFragment = null;
          mFragment = new SalesViewFragment();
  
          Bundle bundle = new Bundle();
  
          bundle.putString(SalesViewFragment.ARG_INVOICE_ID, getIntent().getStringExtra(SalesViewFragment.ARG_INVOICE_ID));
          bundle.putString(SalesViewFragment.ARG_INVOICE_CODE, getIntent().getStringExtra(SalesViewFragment.ARG_INVOICE_CODE));
          bundle.putString(SalesViewFragment.ARG_CUSTOMER_ID, getIntent().getStringExtra(SalesViewFragment.ARG_CUSTOMER_ID));
          bundle.putString(SalesViewFragment.ARG_INVOICE_ORDER_ID, getIntent().getStringExtra(SalesViewFragment.ARG_INVOICE_ORDER_ID));
  
          bundle.putString(SalesViewFragment.ARG_SALES_PERSON, getIntent().getStringExtra(SalesViewFragment.ARG_SALES_PERSON));
          bundle.putString(SalesViewFragment.ARG_INVOICE_CUSTOMER_NAME, getIntent().getStringExtra(SalesViewFragment.ARG_INVOICE_CUSTOMER_NAME));
  
          bundle.putString(SalesViewFragment.ARG_INVOICE_TOTAL, getIntent().getStringExtra(SalesViewFragment.ARG_INVOICE_TOTAL));
          bundle.putString(SalesViewFragment.ARG_START_TIME, getIntent().getStringExtra(SalesViewFragment.ARG_START_TIME));
  
          bundle.putString(SalesViewFragment.ARG_INVOICE_DISCOUNT, getIntent().getStringExtra(SalesViewFragment.ARG_INVOICE_DISCOUNT));
          bundle.putString(SalesViewFragment.ARG_INVOICE_CASH_DISCOUNT, getIntent().getStringExtra(SalesViewFragment.ARG_INVOICE_CASH_DISCOUNT));
          bundle.putString(SalesViewFragment.ARG_INVOICE_DISCOUNT_TRADE, getIntent().getStringExtra(SalesViewFragment.ARG_INVOICE_DISCOUNT_TRADE));
          bundle.putString(SalesViewFragment.ARG_INVOICE_DISCOUNT_PARENTAGE, getIntent().getStringExtra(SalesViewFragment.ARG_INVOICE_DISCOUNT_PARENTAGE));
  
          bundle.putString(SalesViewFragment.ARG_INVOICE_STATUS, getIntent().getStringExtra(SalesViewFragment.ARG_INVOICE_STATUS));
          bundle.putString(SalesViewFragment.ARG_INVOICE_REMARKS, getIntent().getStringExtra(SalesViewFragment.ARG_INVOICE_REMARKS));
  
          mFragment.setArguments(bundle);
  
          FragmentManager fragmentManager = getSupportFragmentManager();
          fragmentManager.beginTransaction()
                  .replace(R.id.frameLayout, mFragment).commit();
  </code></pre>
  
  <p><strong>Here is the salesViewFragment.java</strong></p>
  
  <pre><code>public static final String ARG_INVOICE_ID = "invoiceId";
      public static final String ARG_INVOICE_CODE = "code";
      public static final String ARG_CUSTOMER_ID = "customerId";
      public static final String ARG_INVOICE_ORDER_ID = "orderId";
  
      public static final String ARG_SALES_PERSON = "salesPerson";
      public static final String ARG_INVOICE_CUSTOMER_NAME = "customerName";
  
      public static final String ARG_INVOICE_TOTAL = "total";
      public static final String ARG_START_TIME = "startTime";
  
      public static final String ARG_INVOICE_DISCOUNT = "discount";
      public static final String ARG_INVOICE_CASH_DISCOUNT = "discountCash";
      public static final String ARG_INVOICE_DISCOUNT_TRADE = "discountTrade";
      public static final String ARG_INVOICE_DISCOUNT_PARENTAGE = "discountPerce";
  
      public static final String ARG_INVOICE_STATUS = "invoiceStatus";
      public static final String ARG_INVOICE_REMARKS = "invoiceRemarks";
  </code></pre>
  
  <p>After getting the data to the fragment I'll assign them to the variables. 
  Here is the code :</p>
  
  <pre><code> @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          if (getArguments().containsKey(ARG_INVOICE_ID)) {
  
              invoiceID = getArguments().getInt(ARG_INVOICE_ID);
              code = getArguments().getString(ARG_INVOICE_CODE);
              cusID = getArguments().getInt(ARG_CUSTOMER_ID);
              orderId = getArguments().getInt(ARG_INVOICE_ORDER_ID);
  
              salesPerson = getArguments().getString(ARG_SALES_PERSON);
              cusName = getArguments().getString(ARG_INVOICE_CUSTOMER_NAME);
  
              total = getArguments().getDouble(ARG_INVOICE_TOTAL);
              startTime = getArguments().getString(ARG_START_TIME);
  
              discounts = getArguments().getDouble(ARG_INVOICE_DISCOUNT);
              discoutCash = getArguments().getDouble(ARG_INVOICE_CASH_DISCOUNT);
              discoutTrade = getArguments().getDouble(ARG_INVOICE_DISCOUNT_TRADE);
              discoutParcent = getArguments().getDouble(ARG_INVOICE_DISCOUNT_PARENTAGE);
  
              invoiceStatus = getArguments().getString(ARG_INVOICE_STATUS);
              invoiceRemarks = getArguments().getString(ARG_INVOICE_REMARKS);
          }
      }
  </code></pre>
  
  <p>I have tried lots of solution and read some articles, but did not work for me. If I did something wrong please help me to find it. Any Solutions highly appreciated. Thanks in advance.</p>
  
  <p><strong>Here are some references:</strong></p>
  
  <p><a href="https://stackoverflow.com/questions/22582069/why-getstringextra-doesnt-give-the-proper-output">why getStringExtra doesn&#39;t give the proper output?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/17161074/key-id-expected-parcelable-but-value-was-java-lang-long-while-passing-parceabl">Key _id expected Parcelable but value was java.lang.Long. while passing Parceable object between Activity</a>
  <a href="https://github.com/fechanique/cordova-plugin-fcm/issues/253" rel="nofollow noreferrer">https://github.com/fechanique/cordova-plugin-fcm/issues/253</a></p>