How to replace LoadData().execute();

I just removed Butterknife from my Android app and replaced it with View binding.

This is the old code with Butterknife, which loads the data as expected:

public class PreloadActivity extends AppCompatActivity {

@SuppressLint("NonConstantResourceId")
@BindView(id.progressBar)
ProgressBar progressBar;

@RequiresApi(api = Build.VERSION_CODES.CUPCAKE)
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_preload);

    Unbinder bind = ButterKnife.bind(this);

    /* new LoadData().execute(); */
    new LoadData().execute();
}

@SuppressLint("StaticFieldLeak")
@SuppressWarnings("deprecation")
@RequiresApi(api = Build.VERSION_CODES.CUPCAKE)
private class LoadData extends AsyncTask<Void, Integer, Void>{

    DBHelper helper;
    AppPreference preference;
    double progress;
    double maxprogress = 100;

    public void onPreExecute() {
        helper = new DBHelper(getApplicationContext());
        preference = new AppPreference(getApplicationContext());
    }

    @Override
    protected Void doInBackground(Void... voids) {
        Boolean firstRun = preference.getFirstRun();
        if (firstRun){
            ArrayList<DBModel> combination1 = preLoadRaw(R.raw.comb1text);
            ArrayList<DBModel> combination2 = preLoadRaw(R.raw.comb2text);
            Log.d("length", String.valueOf(combination2.size()));
            publishProgress((int) progress);

            try{
                helper.open();
            } catch (SQLException e){
                e.printStackTrace();
            }

            double progressMaxInsert = 100.0;
            double progressDiff = (progressMaxInsert - progress) /
                    (combination1.size() + combination2.size());

            helper.insertTransaction(combination1, true);
            progress += progressDiff;
            publishProgress((int) progress);

            helper.insertTransaction(combination2, false);
            progress += progressDiff;
            publishProgress((int) progress);

            helper.close();
            preference.setFirstRun(false);

            publishProgress((int) maxprogress);
        }
        else {
            try{
                synchronized (this){
                    this.wait(1000);
                    publishProgress(50);

                    this.wait(300);
                    publishProgress((int) maxprogress);
                }
            } catch (Exception ignored) {
            }
        }
        return null;
    }

    @Override
    protected void onProgressUpdate(Integer... values) {
        progressBar.setProgress(values[0]);
    }

    @Override
    protected void onPostExecute(Void aVoid) {
        Intent i = new Intent(PreloadActivity.this, com.myapp.name.MainActivity.class);
        startActivity(i);
        finish();
    }
}

private ArrayList<DBModel> preLoadRaw(int data) {
    ArrayList<DBModel> list = new ArrayList<>();
    BufferedReader reader;
    try{
        Resources res = getResources();
        InputStream raw_DB = res.openRawResource(data);

        reader = new BufferedReader(new InputStreamReader(raw_DB));
        String line;
        do{
            line =  reader.readLine();
            String[] splitstr = line.split("t");
            DBModel DB;
            DB = new DNModel(splitstr[0], splitstr[1]);
            list.add(DB);
        } while (true);
    }
    catch (Exception e){
        e.printStackTrace();
    }


    return list;
}

Now in the new code, the data doesn’t load anymore. Android Studio tells me that LoadData is never used. The command “execute” does not work. The app crashes. This construction apparently only works with Butterknife. How can I replace it? Any idea what I am doing wrong?

public class PreloadActivity extends AppCompatActivity {

@SuppressLint("NonConstantResourceId")
private ProgressBar progressBar;
//Private field 'progressBar' is never assigned
@RequiresApi(api = Build.VERSION_CODES.CUPCAKE)
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_preload);
    com.myapp.name.databinding.ActivityMainBinding binding = ActivityMainBinding.inflate(getLayoutInflater());
    View view = binding.getRoot();
    setContentView(view);

   new LoadData().execute(); //execute does not work, app crashes

}

@SuppressLint("StaticFieldLeak")
@SuppressWarnings("deprecation")
@RequiresApi(api = Build.VERSION_CODES.CUPCAKE)
private class LoadData extends AsyncTask<Void, Integer, Void>{
//Private inner class 'LoadData' is never used
    DBHelper helper;
    AppPreference preference;
    double progress;
    double maxprogress = 100;

    public void onPreExecute() {
        helper = new DBHelper(getApplicationContext());
        preference = new AppPreference(getApplicationContext());
    }

  @Override
    protected Void doInBackground(Void... voids) {
        Boolean firstRun = preference.getFirstRun();
        if (firstRun){
            ArrayList<DBModel> combination1 = preLoadRaw(R.raw.comb1text);
            ArrayList<DBModel> combination2 = preLoadRaw(R.raw.comb2text);
            Log.d("length", String.valueOf(combination2.size()));
            publishProgress((int) progress);

            try{
                helper.open();
            } catch (SQLException e){
                e.printStackTrace();
            }

            double progressMaxInsert = 100.0;
            double progressDiff = (progressMaxInsert - progress) /
                    (combination1.size() + combination2.size());

            helper.insertTransaction(combination1, true);
            progress += progressDiff;
            publishProgress((int) progress);

            helper.insertTransaction(combination2, false);
            progress += progressDiff;
            publishProgress((int) progress);

            helper.close();
            preference.setFirstRun(false);

            publishProgress((int) maxprogress);
        }
        else {
            try{
                synchronized (this){
                    this.wait(1000);
                    publishProgress(50);

                    this.wait(300);
                    publishProgress((int) maxprogress);
                }
            } catch (Exception ignored) {
            }
        }
        return null;
    }

    @Override
    protected void onProgressUpdate(Integer... values) {
        progressBar.setProgress(values[0]);
    }

    @Override
    protected void onPostExecute(Void aVoid) {
        Intent i = new Intent(PreloadActivity.this, com.myapp.name.MainActivity.class);
        startActivity(i);
        finish();
    }
}

public class LoadDataImpl extends LoadData { }

private ArrayList<DBModel> preLoadRaw(int data) {
    ArrayList<DBModel> list = new ArrayList<>();
    BufferedReader reader;
    try{
        Resources res = getResources();
        InputStream raw_DB = res.openRawResource(data);

        reader = new BufferedReader(new InputStreamReader(raw_DB));
        String line;
        do{
            line =  reader.readLine();
            String[] splitstr = line.split("t");
            DBModel DB;
            DB = new DBModel(splitstr[0], splitstr[1]);
            list.add(DB);
        } while (true);
    }
    catch (Exception e){
        e.printStackTrace();
    }


    return list;
}

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật