getting Null pointer Exception in Android
<p>I am creating an app in android for call logs backup and restore using csv file. I am facing an issue and i am not getting where is the issue here i is the error log please suggest me where is the bug and how to fix it.....</p>

<pre><code>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.&lt;init&gt;(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)
</code></pre>

<p>Here is the code </p>

<pre><code>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);
    }
</code></pre>
