App is getting crashed while retrieving data from SQLite and displaying on Custom list view : I'm trying to retrieve data stored in the database and show it onto custom ListView. Whenever I call FenceActivity.class to view data app gets crashed.

*FenceActivity*

```
public class FenceActivity extends AppCompatActivity {
    List<Fence> fenceList;
    SQLiteDatabase sqLiteDatabase;
    ListView listViewFences;
    FenceAdapter fenceAdapter;
    DataBaseHelper dataBaseHelper;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.savedfences);

        listViewFences = findViewById(R.id.fencesListView);
        fenceList = new ArrayList<>();

        showFencesFromDatabase();
    }

    public void showFencesFromDatabase(){

        dataBaseHelper = new DataBaseHelper(this);
        Cursor cursor = dataBaseHelper.getAllData();

        if(cursor.moveToFirst()){
            do{
                fenceList.add(new Fence(cursor.getInt(0),cursor.getDouble(1),cursor.getDouble(2),cursor.getInt(3)));
            }while (cursor.moveToNext());
        }
        cursor.close();

        fenceAdapter = new FenceAdapter(FenceActivity.this,R.layout.list_layout_fences,fenceList);

        listViewFences.setAdapter(fenceAdapter);
    }

}
```
I use Fence Activity to retrieve Data using DatabaseHelper class from the database.

*Fence Adapter*

```
public class FenceAdapter extends ArrayAdapter<Fence> {

    Context context;
    int listLayoutRes;
    List<Fence> fenceList;

    public FenceAdapter(Context context, int listLayoutRes, List<Fence> fenceList){
        super(context,listLayoutRes,fenceList);
        this.context = context;
        this.listLayoutRes=listLayoutRes;
        this.fenceList = fenceList;
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater layoutInflater = LayoutInflater.from(context);
        View view = layoutInflater.inflate(listLayoutRes,null);

        Fence fence = fenceList.get(position);
        TextView textViewSno = view.findViewById(R.id.textViewSnoLabel);
        TextView textViewLat = view.findViewById(R.id.textViewLatitudeValue);
        TextView textViewLon = view.findViewById(R.id.textViewLongitudeValue);
        TextView textViewRadi = view.findViewById(R.id.textViewRadiusValue);

        textViewSno.setText(fence.getSno());
        textViewLat.setText(String.valueOf(fence.getLat()));
        textViewLon.setText(String.valueOf(fence.getLon()));
        textViewRadi.setText(fence.getRadius());

        Button buttonDel = view.findViewById(R.id.buttonDeleteFence);
        return view;
    }
}
```
This my adapter class to inflate listview.

*Fence*
```
public class Fence {

    int radius,sno;
    double lat,lon;

    public Fence( int sno,double lat, double lon,int radius) {
        this.radius = radius;
        this.sno = sno;
        this.lat = lat;
        this.lon = lon;
    }

    public int getRadius() {
        return radius;
    }

    public int getSno() {
        return sno;
    }

    public double getLat() {
        return lat;
    }

    public double getLon() {
        return lon;
    }
}
```
This my simple Fence class with getters and a constructor.


What changes can I make to prevent my app from getting crashed?