Android:致命错误,SQLite,AsyncTask#1

时间:2016-07-14 18:12:57

标签: android android-asynctask indexoutofboundsexception

我遇到了致命错误的大问题。明天早上我需要应用程序好,所以我开始绝望了。我将不胜感激任何帮助!

这就是错误的样子

07-14 20:06:38.130 10079-10504/jansoldat.formular100 E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
   java.lang.RuntimeException: An error occured while executing doInBackground()
       at android.os.AsyncTask$3.done(AsyncTask.java:299)
       at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
       at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
       at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
       at java.util.concurrent.FutureTask.run(FutureTask.java:137)
       at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
       at java.lang.Thread.run(Thread.java:864)
    Caused by: java.lang.ArrayIndexOutOfBoundsException: length=210; index=210
       at jansoldat.formular100.BackgroundTask.doInBackground(BackgroundTask.java:254)
       at jansoldat.formular100.BackgroundTask.doInBackground(BackgroundTask.java:11)
       at android.os.AsyncTask$2.call(AsyncTask.java:287)
       at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
       at java.util.concurrent.FutureTask.run(FutureTask.java:137) 
       at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) 
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 
       at java.lang.Thread.run(Thread.java:864) 

这是我的BackgroundTask代码

 package jansoldat.formular100;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.os.AsyncTask;
import android.widget.Toast;

/**
 * Created by Ješek on 16. 6. 2016.
 */
public class BackgroundTask extends AsyncTask<String,Void,String> {
    Context ctx;
    byte[] byteArray;
    byte[] byteArray1;


    BackgroundTask(Context ctx)
    {
        this.ctx = ctx;
    }

    BackgroundTask(Context ctx,byte[] byteArray,byte[] byteArray1)
    {
        this.ctx = ctx;
        this.byteArray = byteArray;
        this.byteArray1 = byteArray1;
    }

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
    }


    @Override
    protected String doInBackground(String... params) {

        String method = params[0];
        DbOperace dbOperace = new DbOperace(ctx);
        if (method.equals("add_info"))
        {
            String Usek_kom = params[1];
            String Kod_useku = params[2];
            String Kody_soused_poc = params[3];
            String Kody_soused_end = params[4];
            String Soucast = params[5];
            String GPS_pocatek = params[6];
            String GPS_konec = params[7];
            String Mereni_provedl = params[8];
            String Dne = params[9];
            String Delka_kom = params[10];
            String Typ_kom = params[11];
            String Material = params[12];
            String Nerovnosti_Povrchu = params[13];
            String Velikost_Poruch = params[14];
            String Cetnost_Poruch = params[15];
            String Okraj_vlevo = params[16];
            String Okraj_vpraco = params[17];
            String Prostor_vlevo = params[18];
            String Prostor_vpravo = params[19];
            String orient_poc = params[20];
            String Sirka_0m = params[21];
            String Podelny_Sklon_0m = params[22];
            String Pricny_Sklon_0m = params[23];
            String Sirka_2m = params[24];
            String Podelny_Sklon_2m = params[25];
            String Pricny_Sklon_2m = params[26];
            String Sirka_4m = params[27];
            String Podelny_Sklon_4m = params[28];
            String Pricny_Sklon_4m = params[29];
            String Sirka_6m = params[30];
            String Podelny_Sklon_6m = params[31];
            String Pricny_Sklon_6m = params[32];
            String Sirka_8m = params[33];
            String Podelny_Sklon_8m = params[34];
            String Pricny_Sklon_8m = params[35];
            String Sirka_10m = params[36];
            String Podelny_Sklon_10m = params[37];
            String Pricny_Sklon_10m = params[38];
            String Sirka_12m = params[39];
            String Podelny_Sklon_12m = params[40];
            String Pricny_Sklon_12m = params[41];
            String Sirka_14m = params[42];
            String Podelny_Sklon_14m = params[43];
            String Pricny_Sklon_14m = params[44];
            String Sirka_16m = params[45];
            String Podelny_Sklon_16m = params[46];
            String Pricny_Sklon_16m = params[47];
            String Sirka_18m = params[48];
            String Podelny_Sklon_18m = params[49];
            String Pricny_Sklon_18m = params[50];
            String Sirka_20m = params[51];
            String Podelny_Sklon_20m = params[52];
            String Pricny_Sklon_20m = params[53];
            String Sirka_22m = params[54];
            String Podelny_Sklon_22m = params[55];
            String Pricny_Sklon_22m = params[56];
            String Sirka_24m = params[57];
            String Podelny_Sklon_24m = params[58];
            String Pricny_Sklon_24m = params[59];
            String Sirka_26m = params[60];
            String Podelny_Sklon_26m = params[61];
            String Pricny_Sklon_26m = params[62];
            String Sirka_28m = params[63];
            String Podelny_Sklon_28m = params[64];
            String Pricny_Sklon_28m = params[65];
            String Sirka_30m = params[66];
            String Podelny_Sklon_30m = params[67];
            String Pricny_Sklon_30m = params[68];
            String Sirka_32m = params[69];
            String Podelny_Sklon_32m = params[70];
            String Pricny_Sklon_32m = params[71];
            String Sirka_34m = params[72];
            String Podelny_Sklon_34m = params[73];
            String Pricny_Sklon_34m = params[74];
            String Sirka_36m = params[75];
            String Podelny_Sklon_36m = params[76];
            String Pricny_Sklon_36m = params[77];
            String Sirka_38m = params[78];
            String Podelny_Sklon_38m = params[79];
            String Pricny_Sklon_38m = params[80];
            String Sirka_40m = params[81];
            String Podelny_Sklon_40m = params[82];
            String Pricny_Sklon_40m = params[83];
            String Sirka_42m = params[84];
            String Podelny_Sklon_42m = params[85];
            String Pricny_Sklon_42m = params[86];
            String Sirka_44m = params[87];
            String Podelny_Sklon_44m = params[88];
            String Pricny_Sklon_44m = params[89];
            String Sirka_46m = params[90];
            String Podelny_Sklon_46m = params[91];
            String Pricny_Sklon_46m = params[92];
            String Sirka_48m = params[93];
            String Podelny_Sklon_48m = params[94];
            String Pricny_Sklon_48m = params[95];
            String Sirka_50m = params[96];
            String Podelny_Sklon_50m = params[97];
            String Pricny_Sklon_50m = params[98];
            String Sirka_52m = params[99];
            String Podelny_Sklon_52m = params[100];
            String Pricny_Sklon_52m = params[101];
            String Sirka_54m = params[102];
            String Podelny_Sklon_54m = params[103];
            String Pricny_Sklon_54m = params[104];
            String Sirka_56m = params[105];
            String Podelny_Sklon_56m = params[106];
            String Pricny_Sklon_56m = params[107];
            String Sirka_58m = params[108];
            String Podelny_Sklon_58m = params[109];
            String Pricny_Sklon_58m = params[110];
            String Sirka_60m = params[110];
            String Podelny_Sklon_60m = params[112];
            String Pricny_Sklon_60m = params[113];
            String Sirka_62m = params[114];
            String Podelny_Sklon_62m = params[115];
            String Pricny_Sklon_62m = params[116];
            String Sirka_64m = params[117];
            String Podelny_Sklon_64m = params[118];
            String Pricny_Sklon_64m = params[119];
            String Sirka_66m = params[120];
            String Podelny_Sklon_66m = params[121];
            String Pricny_Sklon_66m = params[122];
            String Sirka_68m = params[123];
            String Podelny_Sklon_68m = params[124];
            String Pricny_Sklon_68m = params[125];
            String Sirka_70m = params[126];
            String Podelny_Sklon_70m = params[127];
            String Pricny_Sklon_70m = params[128];
            String Sirka_72m = params[129];
            String Podelny_Sklon_72m = params[130];
            String Pricny_Sklon_72m = params[131];
            String Sirka_74m = params[132];
            String Podelny_Sklon_74m = params[133];
            String Pricny_Sklon_74m = params[134];
            String Sirka_76m = params[135];
            String Podelny_Sklon_76m = params[136];
            String Pricny_Sklon_76m = params[137];
            String Sirka_78m = params[138];
            String Podelny_Sklon_78m = params[139];
            String Pricny_Sklon_78m = params[140];
            String Sirka_80m = params[141];
            String Podelny_Sklon_80m = params[142];
            String Pricny_Sklon_80m = params[143];
            String Sirka_82m = params[144];
            String Podelny_Sklon_82m = params[145];
            String Pricny_Sklon_82m = params[146];
            String Sirka_84m = params[147];
            String Podelny_Sklon_84m = params[148];
            String Pricny_Sklon_84m = params[149];
            String Sirka_86m = params[150];
            String Podelny_Sklon_86m = params[151];
            String Pricny_Sklon_86m = params[152];
            String Sirka_88m = params[153];
            String Podelny_Sklon_88m = params[154];
            String Pricny_Sklon_88m = params[155];
            String Sirka_90m = params[156];
            String Podelny_Sklon_90m = params[157];
            String Pricny_Sklon_90m = params[158];
            String Sirka_92m = params[159];
            String Podelny_Sklon_92m = params[160];
            String Pricny_Sklon_92m = params[161];
            String Sirka_94m = params[162];
            String Podelny_Sklon_94m = params[163];
            String Pricny_Sklon_94m = params[164];
            String Sirka_96m = params[165];
            String Podelny_Sklon_96m = params[166];
            String Pricny_Sklon_96m = params[167];
            String Sirka_98m = params[168];
            String Podelny_Sklon_98m = params[169];
            String Pricny_Sklon_98m = params[170];
            String Sirka_100m = params[171];
            String Podelny_Sklon_100m = params[172];
            String Pricny_Sklon_100m = params[173];
            String Orient_konec = params[174];
            String Staniceni1 = params[173];
            String Parametry = params[173];
            String Staniceni2 = params[174];
            String Parametry2 = params[175];
            String Staniceni3 = params[176];
            String Parametry3 = params[177];
            String Staniceni4 = params[178];
            String Parametry4 = params[179];
            String Staniceni5 = params[180];
            String Parametry5 = params[181];
            String Staniceni6 = params[182];
            String Parametry6 = params[183];
            String Staniceni7 = params[184];
            String Parametry7 = params[185];
            String Staniceni8 = params[186];
            String Parametry8 = params[187];
            String Staniceni9 = params[188];
            String Parametry9 = params[189];
            String Staniceni10 = params[190];
            String Parametry10 = params[191];
            String Staniceni11 = params[192];
            String Parametry11 = params[193];
            String Staniceni12 = params[194];
            String Parametry12 = params[195];
            String Staniceni13 = params[196];
            String Parametry13 = params[197];
            String Staniceni14 = params[198];
            String Parametry14 = params[199];
            String Staniceni15 = params[200];
            String Parametry15 = params[201];
            String Staniceni16 = params[202];
            String Parametry16 = params[203];
            String Staniceni17 = params[204];
            String Parametry17 = params[205];
            String Staniceni18 = params[206];
            String Parametry18 = params[207];
            String Staniceni19 = params[208];
            String Parametry19 = params[209];
            String Staniceni20 = params[210];
            String Parametry20 = params[211];
            String Poznamky = params[212];



            // byte[] ObrazekGalerie = params[7];
            SQLiteDatabase db = dbOperace.getWritableDatabase();
            dbOperace.pridejInformace(db,Usek_kom,Kod_useku,Kody_soused_poc,Kody_soused_end,Soucast,GPS_pocatek,GPS_konec,Mereni_provedl,Dne,Delka_kom,Typ_kom,Material,Nerovnosti_Povrchu,Velikost_Poruch,Cetnost_Poruch
                    ,Okraj_vlevo,Okraj_vpraco,Prostor_vlevo,Prostor_vpravo,orient_poc,Sirka_0m,Podelny_Sklon_0m,Pricny_Sklon_0m,Sirka_2m,Podelny_Sklon_2m,Pricny_Sklon_2m,Sirka_4m,Podelny_Sklon_4m,Pricny_Sklon_4m,
                    Sirka_6m,Podelny_Sklon_6m,Pricny_Sklon_6m, Sirka_8m,Podelny_Sklon_8m,Pricny_Sklon_8m, Sirka_10m,Podelny_Sklon_10m,Pricny_Sklon_10m,Sirka_12m,Podelny_Sklon_12m,Pricny_Sklon_12m,
                    Sirka_14m,Podelny_Sklon_14m,Pricny_Sklon_14m,Sirka_16m,Podelny_Sklon_16m,Pricny_Sklon_16m,Sirka_18m,Podelny_Sklon_18m,Pricny_Sklon_18m,Sirka_20m,Podelny_Sklon_20m,Pricny_Sklon_20m,
                    Sirka_22m,Podelny_Sklon_22m,Pricny_Sklon_22m,Sirka_24m,Podelny_Sklon_24m,Pricny_Sklon_24m,Sirka_26m,Podelny_Sklon_26m,Pricny_Sklon_26m,Sirka_28m,Podelny_Sklon_28m,Pricny_Sklon_28m,
                    Sirka_30m,Podelny_Sklon_30m,Pricny_Sklon_30m,Sirka_32m,Podelny_Sklon_32m,Pricny_Sklon_32m,Sirka_34m,Podelny_Sklon_34m,Pricny_Sklon_34m,Sirka_36m,Podelny_Sklon_36m,Pricny_Sklon_36m,Sirka_38m,Podelny_Sklon_38m,Pricny_Sklon_38m,
                    Sirka_40m,Podelny_Sklon_40m,Pricny_Sklon_40m,Sirka_42m,Podelny_Sklon_42m,Pricny_Sklon_42m,Sirka_44m,Podelny_Sklon_44m,Pricny_Sklon_44m,Sirka_46m,Podelny_Sklon_46m,Pricny_Sklon_46m,Sirka_48m,Podelny_Sklon_48m,Pricny_Sklon_48m,
                    Sirka_50m,Podelny_Sklon_50m,Pricny_Sklon_50m,Sirka_52m,Podelny_Sklon_52m,Pricny_Sklon_52m,Sirka_54m,Podelny_Sklon_54m,Pricny_Sklon_54m,Sirka_56m,Podelny_Sklon_56m,Pricny_Sklon_56m,Sirka_58m,Podelny_Sklon_58m,Pricny_Sklon_58m,
                    Sirka_60m,Podelny_Sklon_60m,Pricny_Sklon_60m,Sirka_62m,Podelny_Sklon_62m,Pricny_Sklon_62m,Sirka_64m,Podelny_Sklon_64m,Pricny_Sklon_64m,Sirka_66m,Podelny_Sklon_66m,Pricny_Sklon_66m,
                    Sirka_68m,Podelny_Sklon_68m,Pricny_Sklon_68m,Sirka_70m,Podelny_Sklon_70m,Pricny_Sklon_70m,Sirka_72m,Podelny_Sklon_72m,Pricny_Sklon_72m,Sirka_74m,Podelny_Sklon_74m,Pricny_Sklon_74m,
                    Sirka_76m,Podelny_Sklon_76m,Pricny_Sklon_76m,Sirka_78m,Podelny_Sklon_78m,Pricny_Sklon_78m,Sirka_80m,Podelny_Sklon_80m,Pricny_Sklon_80m,Sirka_82m,Podelny_Sklon_82m,Pricny_Sklon_82m,
                    Sirka_84m,Podelny_Sklon_84m,Pricny_Sklon_84m,Sirka_86m,Podelny_Sklon_86m,Pricny_Sklon_86m,Sirka_88m,Podelny_Sklon_88m,Pricny_Sklon_88m,Sirka_90m,Podelny_Sklon_90m,Pricny_Sklon_90m,Sirka_92m,Podelny_Sklon_92m,Pricny_Sklon_92m,
                    Sirka_94m,Podelny_Sklon_94m,Pricny_Sklon_94m,Sirka_96m,Podelny_Sklon_96m,Pricny_Sklon_96m,Sirka_98m,Podelny_Sklon_98m,Pricny_Sklon_98m,Sirka_100m,Podelny_Sklon_100m,Pricny_Sklon_100m,Orient_konec,
                    Staniceni1,Parametry,Staniceni2,Parametry2,Staniceni3,Parametry3,Staniceni4,Parametry4,Staniceni5,Parametry5,Staniceni6,Parametry6,Staniceni7,Parametry7,Staniceni8,Parametry8,Staniceni9,Parametry9
                    ,Staniceni10,Parametry10,Staniceni11,Parametry11,Staniceni12,Parametry12,Staniceni13,Parametry13,Staniceni14,Parametry14,Staniceni15,Parametry15,Staniceni16,Parametry16,Staniceni17,Parametry17,Staniceni18,Parametry18
                    ,Staniceni19,Parametry19,Staniceni20,Parametry20,Poznamky,
                    byteArray, byteArray1);
            return "Zápis uložen....";
        }

        return null;
    }

    @Override
    protected void onProgressUpdate(Void... values){
        super.onProgressUpdate(values);
    }

    @Override
    protected void onPostExecute(String result){
        Toast.makeText(ctx,result,Toast.LENGTH_LONG).show();
    }

2 个答案:

答案 0 :(得分:1)

Caused by: java.lang.ArrayIndexOutOfBoundsException: length=210; index=210

我认为你在这一行中有错误:

String Staniceni20 = params[210];

简单 - paramns []有210而你正试图获得第211个

答案 1 :(得分:0)

它表示你的索引和长度是210,但在你的代码列表中你有212个项目,这可能与它有关。我能想到的唯一另一件事是,如果你正在做一个指数0计算,那么试着让你的指数211和210的长度?