'SQLiteOutOfMemoryException, inserting 97k data into a SQLITE database on android

I created a SQLITE bank for my application, when I try to insert one of the bases that contains 97 thousand lines it gives the error failed to allocate 120000 bytes of memory and then Out Of Memory, could someone help me how I can do it to be able to insert a large amount of data in a table of a SQLite database on android.

this is the function of my repository that I'm using to insert the data:

        public long InsertWeb(AreaEmp item) {

        long retorn = 0;

        try {



          ContentValues contentValues = new ContentValues();

            contentValues.put("_id", item.get_id());
            contentValues.put("no_divisao_1", item.getNo_divisao_1());
            contentValues.put("no_divisao_2", item.getNo_divisao_2());
            contentValues.put("no_divisao_3", item.getNo_divisao_3());
            contentValues.put("no_divisao_4", item.getNo_divisao_4());
            contentValues.put("ds_divisao_1", item.getDs_divisao_1());
            contentValues.put("ds_divisao_2", item.getDs_divisao_2());
            contentValues.put("ds_divisao_3", item.getDs_divisao_3());
            contentValues.put("ds_divisao_4", item.getDs_divisao_4());
            contentValues.put("cd_subregiao", item.getCd_subregiao());
            contentValues.put("dt_plantio", item.getDt_plantio());
            contentValues.put("id_empresa", item.getId_empresa());
            contentValues.put("id_talhao", item.getId_talhao());
            contentValues.put("id_tipo_uso", item.getId_tipo_uso());
            contentValues.put("id_versao", item.getId_versao());
            contentValues.put("no_municipio", item.getNo_municipio());
            contentValues.put("no_ordem", item.getNo_ordem());
            contentValues.put("nu_bloco", item.getNu_bloco());
            contentValues.put("vl_area", item.getVl_area());
            contentValues.put("vl_espac_linha", item.getVl_espac_linha());
            contentValues.put("vl_espac_planta", item.getVl_espac_planta());

            resultInsert = sqLiteDatabase.insertOrThrow(table, null, contentValues);
            contentValues.clear();
            //sqLiteDatabase.setTransactionSuccessful();


        } finally {
            if (sqLiteDatabase != null && sqLiteDatabase.inTransaction()) {
                sqLiteDatabase.endTransaction();
            }
        }
        return  resultInsert;
    }

and this is the function that calls in main to insert all the items in the list:


     for (AreaEmp item : list){

                    new AreaEmpRepositorio(context).InsertWeb(item);





                }



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source