title: Android serializable reads only one object
body: <p>serializable list reads only one object.</p>
  
  <p>Class department</p>
  
  <pre><code>public class Department implements Serializable {
  
  int Id;
  String DepartmentName;
  int Status;
  
  public Department(){
  
  }
  public Department(String Name, int faculty){
      this.DepartmentName = Name;
      this.Status = faculty;
  }
  
  public Department(int id, String name, int faculty){
      this.Id = id;
      this.DepartmentName = name;
      this.Status = faculty;
  }
  
  public int getId() {
      return this.Id;
  }
  
  public void setId(int id) {
      Id = id;
  }
  
  public String getDepartmentName() {
      return this.DepartmentName;
  }
  
  public void setDepartmentName(String departmentName) {
      DepartmentName = departmentName;
  }
  
  public int getStatus() {
      return this.Status;
  }
  
  public void setFaculty(int faculty) {
      Status = faculty;
  }
  
  public String toString(){
      return DepartmentName;
  }
  }
  </code></pre>
  
  <p>Main menu activity</p>
  
  <pre><code>public class MainMenu extends AppCompatActivity {
  
  DataBase dataBase = new DataBase(this);
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main_menu);
  
      //create faculty
      Faculty Science = new Faculty("Science");
      long Science_id = dataBase.CreateFaculty(Science);
  
      // create department
      Department computer = new Department("Computer", 0);
      Department maths = new Department("Maths",0);
      Department EMT = new Department("Environmental Science",0);
      Department physics = new Department("Physics",0);
  
      long comp_id = dataBase.CreateDepartment(computer, new long[]{Science_id});
      long math_id = dataBase.CreateDepartment(maths, new long[]{Science_id});
      long emt_id = dataBase.CreateDepartment(EMT, new long[]{Science_id});
      long physics_id = dataBase.CreateDepartment(physics, new long[]{Science_id});
  
      Log.d("Sciences:", "Science Departments " + dataBase.GetDepartmentsBYFac("Science"));
  
  
      // list of science departments
      // final List&lt;Department&gt; sci_departments = dataBase.GetDepartmentsBYFac("Science");
  
      ImageButton imageButton = (ImageButton) findViewById(R.id.science);
      imageButton.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent intent = new Intent(MainMenu.this, DepartmentsActivity.class);
              List&lt;Department&gt; departments = new ArrayList&lt;Department&gt;();
              departments = dataBase.GetDepartmentsBYFac("Science");
              Bundle bundle = new Bundle();
              bundle.putSerializable("Sciences", (Serializable) departments);
              intent.putExtra("Bundle", bundle);
              startActivity(intent);
          }
      });
  
  
  }
  </code></pre>
  
  <p>Receiving activity (listview)</p>
  
  <pre><code>public class DepartmentsActivity extends ListActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_departments);
  
      DataBase dataBase = new DataBase(this);
      Intent intent = getIntent();
      Bundle bundle = intent.getBundleExtra("Bundle");
      List&lt;Department&gt; departments = (ArrayList&lt;Department&gt;) bundle.getSerializable("Sciences");
  
      ArrayAdapter&lt;Department&gt; adapter = new ArrayAdapter&lt;Department&gt;(this, android.R.layout.simple_list_item_1, departments);
      setListAdapter(adapter);
  
  }
  
  }
  </code></pre>
  
  <p>the listview result shows </p>
  
  <pre><code>physics 
  physics 
  physics 
  physics
  </code></pre>
  
  <p>here is the method for CreateDeppartment</p>
  
  <pre><code>public long CreateDepartment(Department department, long[] fac_ids){
  
      SQLiteDatabase database = this.getWritableDatabase();
  
      values = new ContentValues();
  
      values.put(KEY_DEPARTMENT, department. getDepartmentName());
  
      values.put(KEY_STATUS, department.getStatus()); 
  
      long dept_id =database.insert(TABLE_DEPARTMENT, null, values); 
  
             for (long fac_id: fac_ids) { 
  
                CreateDeptStatus(dept_id, fac_id);
             } 
  
  
  
     return  dept__id;
  } 
  </code></pre>
  
  <p>here is the warning </p>
  
  <pre><code>Unchecked cast: 'java.io.Serializable' to 'java.util.ArrayList&lt;com.example.umar.album.Models.Department&gt;' less... (Ctrl+F1) 
   Signals places where an unchecked warning is issued by the compiler, for example:
  void f(HashMap map) {
    map.put("key", "value");
    }
  
  Hint: Pass -Xlint:unchecked to javac to get more details.
  </code></pre>