0

我正在 android 中创建一个应用程序,用于使用 csv 文件备份和恢复通话记录。我面临一个问题,我没有得到问题在哪里我是错误日志请建议我错误在哪里以及如何修复它.....

04-02 16:26:10.284: E/AndroidRuntime(7030): FATAL EXCEPTION: AsyncTask #1
04-02 16:26:10.284: E/AndroidRuntime(7030): java.lang.RuntimeException: An error   occured while executing doInBackground()
04-02 16:26:10.284: E/AndroidRuntime(7030):     at android.os.AsyncTask$3.done(AsyncTask.java:299)
04-02 16:26:10.284: E/AndroidRuntime(7030):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
04-02 16:26:10.284: E/AndroidRuntime(7030):     at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
04-02 16:26:10.284: E/AndroidRuntime(7030):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
04-02 16:26:10.284: E/AndroidRuntime(7030):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
04-02 16:26:10.284: E/AndroidRuntime(7030):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
04-02 16:26:10.284: E/AndroidRuntime(7030):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
04-02 16:26:10.284: E/AndroidRuntime(7030):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
04-02 16:26:10.284: E/AndroidRuntime(7030):     at java.lang.Thread.run(Thread.java:856)
04-02 16:26:10.284: E/AndroidRuntime(7030): Caused by: java.lang.NullPointerException
04-02 16:26:10.284: E/AndroidRuntime(7030):     at android.os.Parcel.readException(Parcel.java:1431)
04-02 16:26:10.284: E/AndroidRuntime(7030):     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:188)
04-02 16:26:10.284: E/AndroidRuntime(7030):     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140)
04-02 16:26:10.284: E/AndroidRuntime(7030):     at android.content.ContentProviderProxy.insert(ContentProviderNative.java:420)
04-02 16:26:10.284: E/AndroidRuntime(7030):     at   android.content.ContentResolver.insert(ContentResolver.java:866)
04-02 16:26:10.284: E/AndroidRuntime(7030):     at com.example.androidbackuppro.Restore.RestoreCallLogs(Restore.java:396)
04-02 16:26:10.284: E/AndroidRuntime(7030):     at com.example.androidbackuppro.Restore$CallLogsRestore.doInBackground(Restore.java:318)
04-02 16:26:10.284: E/AndroidRuntime(7030):     at com.example.androidbackuppro.Restore$CallLogsRestore.doInBackground(Restore.java:1)
04-02 16:26:10.284: E/AndroidRuntime(7030):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
04-02 16:26:10.284: E/AndroidRuntime(7030):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
04-02 16:26:10.284: E/AndroidRuntime(7030):     ... 5 more
04-02 16:26:19.329: I/Choreographer(7030): Skipped 508 frames!  The application may be doing too much work on its main thread.
04-02 16:26:19.724: E/SpannableStringBuilder(7030): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
04-02 16:26:19.729: E/SpannableStringBuilder(7030): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
04-02 16:26:19.764: W/IInputConnectionWrapper(7030): getSelectedText on inactive InputConnection
04-02 16:26:19.784: W/IInputConnectionWrapper(7030): setComposingText on inactive InputConnection
04-02 16:26:19.829: E/WindowManager(7030): Activity com.example.androidbackuppro.Restore has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41bd7850 that was originally added here
04-02 16:26:19.829: E/WindowManager(7030): android.view.WindowLeaked: Activity com.example.androidbackuppro.Restore has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41bd7850 that was originally added here
04-02 16:26:19.829: E/WindowManager(7030):  at android.view.ViewRootImpl.<init>(ViewRootImpl.java:409)
04-02 16:26:19.829: E/WindowManager(7030):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:322)
04-02 16:26:19.829: E/WindowManager(7030):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:234)
04-02 16:26:19.829: E/WindowManager(7030):  at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:153)
04-02 16:26:19.829: E/WindowManager(7030):  at android.view.Window$LocalWindowManager.addView(Window.java:559)
04-02 16:26:19.829: E/WindowManager(7030):  at android.app.Dialog.show(Dialog.java:277)
04-02 16:26:19.829: E/WindowManager(7030):  at com.example.androidbackuppro.Restore$CallLogsRestore.onPreExecute(Restore.java:297)
04-02 16:26:19.829: E/WindowManager(7030):  at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:586)
04-02 16:26:19.829: E/WindowManager(7030):  at android.os.AsyncTask.execute(AsyncTask.java:534)
04-02 16:26:19.829: E/WindowManager(7030):  at com.example.androidbackuppro.Restore.CallLogsRestore(Restore.java:92)
04-02 16:26:19.829: E/WindowManager(7030):  at java.lang.reflect.Method.invokeNative(Native Method)
04-02 16:26:19.829: E/WindowManager(7030):  at java.lang.reflect.Method.invoke(Method.java:511)
04-02 16:26:19.829: E/WindowManager(7030):  at android.view.View$1.onClick(View.java:3719)
04-02 16:26:19.829: E/WindowManager(7030):  at android.view.View.performClick(View.java:4261)
04-02 16:26:19.829: E/WindowManager(7030):  at android.view.View$PerformClick.run(View.java:17356)
04-02 16:26:19.829: E/WindowManager(7030):  at android.os.Handler.handleCallback(Handler.java:615)
04-02 16:26:19.829: E/WindowManager(7030):  at android.os.Handler.dispatchMessage(Handler.java:92)
04-02 16:26:19.829: E/WindowManager(7030):  at android.os.Looper.loop(Looper.java:137)
04-02 16:26:19.829: E/WindowManager(7030):  at android.app.ActivityThread.main(ActivityThread.java:4921)
04-02 16:26:19.829: E/WindowManager(7030):  at java.lang.reflect.Method.invokeNative(Native Method)
04-02 16:26:19.829: E/WindowManager(7030):  at java.lang.reflect.Method.invoke(Method.java:511)
04-02 16:26:19.829: E/WindowManager(7030):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
04-02 16:26:19.829: E/WindowManager(7030):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
04-02 16:26:19.829: E/WindowManager(7030):  at dalvik.system.NativeStart.main(Native Method)

这是代码

folder = new File(Environment.getExternalStorageDirectory() + File.separator + getString(R.string.app_name));
            String csvFilename = folder+"/CallLogs.csv";
            if(IsFileExists(csvFilename))
            {

            CSVReader csvReader = new CSVReader(new FileReader(csvFilename), ',', '\'', 0);
            String[] row = null;
            if(csvReader.readNext()!=null)
            {
                 while((row = csvReader.readNext()) != null)
                     {
                    RestoreCallLogs(row[0],row[1],row[2],row[3],row[4]);

                    }
                 csvReader.close();
                 //If Restoration is successful
                IsRestore="1";
              }

 public  void RestoreCallLogs(String Name,String number,String Date,String Type,String Duration){
        ContentValues values = new ContentValues();
        values.put(CallLog.Calls.NUMBER, number);
        values.put(CallLog.Calls.DATE, Date);
        values.put(CallLog.Calls.DURATION,Duration);
        values.put(CallLog.Calls.TYPE, Type);
        /* if(Type=="Incoming")
           values.put(CallLog.Calls.TYPE, 1);
        else if(Type=="Missed")
            values.put(CallLog.Calls.TYPE, 2);
        else
            values.put(CallLog.Calls.TYPE, 3);*/
        if(Name!="Unknown")
         values.put(CallLog.Calls.CACHED_NAME, Name);
        getContentResolver().insert(CallLog.Calls.CONTENT_URI, values);
    }
4

0 回答 0