title: file input stream need to read from the Object
body: <p>I am trying to save data onDestroy method inside a bottomsheetDialogFragment. I am saving information on destroy method and getting saved info onCreate method.</p>
  <p>but I am getting an error on this particular line</p>
  <pre><code>listOfItem= new ArrayList&lt;&gt; (Arrays.asList ( split ) );
  </code></pre>
  <p>I am adding list using recylerView from Item class but I don't know how to add split string into the ArrayList.</p>
  <p>hope you understand my question. below is my code thanks very much</p>
  <pre><code>public class CustomFragment_1 extends BottomSheetDialogFragment {
  
  private RecyclerView recyclerView;
  private CustomAdapter_1 mAdapter;
  ArrayList&lt;Item&gt; listOfItem;
  
  
  String cName;
  Button btn;
  FlatDialog flatDialog;
  EditText editText;
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      // Inflate the layout for this fragment
      View view = inflater.inflate ( R.layout.fragment_custom_1, container, false );
  
  
      recyclerView = (RecyclerView) view.findViewById ( R.id.customRV );
      btn = (Button) view.findViewById ( R.id.button1 );
      editText = (EditText) view.findViewById ( R.id.edt1 );
  
  
      LinearLayoutManager linearLayoutManager = new LinearLayoutManager ( getContext () );
      recyclerView.setLayoutManager ( linearLayoutManager );
  
      listOfItem = new ArrayList&lt;&gt; ();
  
      mAdapter = new CustomAdapter_1 ( getContext (), listOfItem );
      recyclerView.setAdapter ( mAdapter );
  
      listOfItem.add ( new Item ( &quot;FreeNow&quot; ) );
      listOfItem.add ( new Item ( &quot;Uber&quot; ) );
      listOfItem.add ( new Item ( &quot;Bolt&quot; ) );
  
  
      btn.setOnClickListener ( new View.OnClickListener () {
          @Override
          public void onClick(View view) {
  
  
              flatDialog = new FlatDialog ( getActivity () );
              flatDialog.setTitle ( &quot;Company Name&quot; )
                      .setSubtitle ( &quot;Please add the name of the company&quot; )
                      .setFirstTextFieldHint ( &quot;Company Name&quot; )
                      .setFirstButtonText ( &quot;ADD&quot; )
                      .setSecondButtonText ( &quot;CANCEL&quot; )
                      .withFirstButtonListner ( new View.OnClickListener () {
                          @Override
                          public void onClick(View view) {
  
                              cName = flatDialog.getFirstTextField ();
                              listOfItem.add ( new Item ( cName ) );
                              mAdapter.notifyItemInserted ( listOfItem.size () );
  
                              flatDialog.dismiss ();
  
                          }
                      } )
                      .withSecondButtonListner ( new View.OnClickListener () {
                          @Override
                          public void onClick(View view) {
                              flatDialog.dismiss ();
                          }
                      } )
                      .show ();
  
  
          }
  
      } );
  
      loadContent ();
      return view;
  }
  
  public void loadContent() {
      File path = getActivity ().getFilesDir ();
      File readFrom = new File ( path, &quot;list.txt&quot; );
      byte[] content = new byte[(int) readFrom.length ()];
  
      FileInputStream stream = null;
  
      try {
          stream = new FileInputStream ( readFrom );
          stream.read ( content );
  
          String s = new String ( content );
          s = s.substring ( 1, s.length () - 1 );
          String split[] = s.split ( &quot;, &quot; );
  
          listOfItem = new ArrayList&lt;&gt; ( Arrays.asList ( split ) );
  
          mAdapter = new CustomAdapter_1 ( getContext (), listOfItem );
          recyclerView.setAdapter ( mAdapter );
      } catch (Exception e) {
          e.printStackTrace ();
      }
  
  
  }
  
  @Override
  public void onDestroy() {
      File path = getContext ().getFilesDir ();
      try {
          FileOutputStream writer = new FileOutputStream ( new File ( path, &quot;list.txt&quot; ) );
          writer.write ( listOfItem.toString ().getBytes () );
          writer.close ();
      } catch (Exception e) {
          e.printStackTrace ();
      }
  
  
      super.onDestroy ();
  }
  </code></pre>
  <p>}</p>
  <p>below is the error I am getting</p>
  <pre><code>error: incompatible types: cannot infer type arguments for ArrayList&lt;&gt;
          listOfItem = new ArrayList&lt;&gt; ( Arrays.asList ( split ) );
                                    ^
  reason: inference variable E has incompatible bounds
    equality constraints: Item
    lower bounds: T,String
  where E,T are type-variables:
  E extends Object declared in class ArrayList
  T extends Object declared in method &lt;T&gt;asList(T...)
  </code></pre>