title: Futuretask Async Error SQlite Android
body: <p>I am facing an issue with transactions on my application. So as a brief, I am building a program to retrieve call records. This works well and fast on the emulator but unfortunately when I try this on my phone which has around 300 call logs, it takes a super long time! I read that creating a single transaction would speed up things. However, when I tried this, i end up with the below error. now I think it might just be a matter of where I am placing my brackets and my endtransaction command but i am unable to figure this out. The error on log cat does not seem to give more information than point to the line and tell me its a null exception. please find code and error log below. Other details will be posted if required.</p>
  <p>thank you!</p>
  <p><strong>My Main Screen.</strong></p>
  <pre><code>   @SuppressWarnings({ &quot;deprecation&quot;, &quot;deprecation&quot; })
  
     public class EtiMainScreen extends TabActivity {
  
  CallRecords recdb = new CallRecords(EtiMainScreen.this);
  
  SQLiteDatabase calllog;
  Context c = this;
  Handler hand = new Handler();
  
  TextView tvnatbun, tvnatrate, tvnatsms, tvintmbun, tvintmrate, tvsmsbun,
          tvsmsrate, tvintsmsrate, tvdatalbun, tvdatalrate, tvpackname,
          tvTotal;
  private long mStartRX = 0;
  private long mStartTX = 0;
  
  @SuppressWarnings(&quot;deprecation&quot;)
  protected void onCreate(Bundle Bundle) {
      super.onCreate(Bundle);
  
      setContentView(R.layout.eti_main_screen);
      super.onCreate(Bundle);
  
      TabHost tabHost = getTabHost();
  
      TabHost.TabSpec spec = getTabHost().newTabSpec(&quot;tag1&quot;);
      spec.setContent(R.id.mainmenu);
      spec.setIndicator(&quot;Main Menu&quot;);
      getTabHost().addTab(spec);
  
      getTabHost().setCurrentTab(0);
  
      spec = getTabHost().newTabSpec(&quot;tag2&quot;);
      spec.setContent(R.id.billhist);
      spec.setIndicator(&quot;Billing History&quot;);
      getTabHost().addTab(spec);
  
      for (int i = 0; i &lt; tabHost.getTabWidget().getChildCount(); i++) {
          TextView tv = (TextView) tabHost.getTabWidget().getChildAt(i)
                  .findViewById(android.R.id.title);
          tv.setTextColor(Color.parseColor(&quot;#FFFFFF&quot;));
      }
  
      TextView tv = (TextView) tabHost.getCurrentTabView().findViewById(
              android.R.id.title);
      tv.setTextColor(Color.parseColor(&quot;#FFFFFF&quot;));
  
      ((Button) findViewById(R.id.alert))
              .setOnClickListener(new View.OnClickListener() {
                  public void onClick(View v) {
  
                      Intent localIntent = new 
            Intent(EtiMainScreen.this,
                              Alerts.class);
                      
         EtiMainScreen.this.startActivity(localIntent);
                  }
              });
  
      Uri SMSsentQuery = Uri.parse(&quot;content://sms/sent&quot;);
  
      Cursor cursor1 = getContentResolver().query(SMSsentQuery, null, null,
              null, null);
  
      Cursor managedCursor = getContentResolver().query(
              android.provider.CallLog.Calls.CONTENT_URI, null,   
             null,null,null);
  
      mStartRX = TrafficStats.getMobileRxBytes();
      mStartTX = TrafficStats.getMobileTxBytes();
      long Totalbytes = mStartRX + mStartTX;
  
      Log.v(&quot;&quot;, Long.toString(mStartRX));
      Log.v(&quot;&quot;, Long.toString(mStartTX));
      Log.v(&quot;&quot;, Long.toString(Totalbytes));
      // int usage = Long.bitCount(Totalbytes) / 1024;
  
      calllog.beginTransaction();
      try {
  
          while (managedCursor.moveToNext()) {
  
              calllog.yieldIfContendedSafely();
              String callNumber = managedCursor.getString(managedCursor
                      .getColumnIndex(CallLog.Calls.NUMBER));
              String callType = managedCursor.getString(managedCursor
                      .getColumnIndex(CallLog.Calls.TYPE));
              String callDur = managedCursor.getString(managedCursor
                      .getColumnIndex(CallLog.Calls.DURATION));
              int dateId = managedCursor
          .getColumnIndex(android.provider.CallLog.Calls.DATE);
  
              long callDate = managedCursor.getLong(dateId);
              SimpleDateFormat datePattern = new SimpleDateFormat(
                      &quot;yyyy-MM-dd HH:mm&quot;);
              String date_str = datePattern.format(new Date(callDate));
  
              int dircode = Integer.parseInt(callType);
              float value = Float.parseFloat(callDur);
              float callDuration = value / 60;
  
              recdb.open();
  
              ContentValues cv = new ContentValues();
  
              if (dircode == CallLog.Calls.OUTGOING_TYPE) {
                  if (callNumber.startsWith(&quot;00971&quot;)
                          || callNumber.startsWith(&quot;05&quot;)
                          || callNumber.startsWith(&quot;04&quot;)
                          || callNumber.startsWith(&quot;03&quot;)
                          || callNumber.startsWith(&quot;02&quot;)) {
  
                      cv.put(&quot;cnatdur&quot;, callDuration);
                  } else {
                      cv.put(&quot;cintdur&quot;, callDuration);
                  }
              }
              int natsms = 0, intsms = 0;
  
              while (cursor1.moveToNext()) {
                  String address = cursor1.getString(cursor1
                          .getColumnIndex(&quot;address&quot;));
  
                  if (address.startsWith(&quot;009-71&quot;)
                          || address.startsWith(&quot;(05&quot;)
                          || address.startsWith(&quot;05&quot;)) {
  
                      natsms++;
                      cv.put(&quot;natsms&quot;, natsms);
  
                  } else {
                      intsms++;
  
                      cv.put(&quot;intsms&quot;, intsms);
                  }
  
                  cv.put(&quot;cdate&quot;, date_str);
                  cv.put(&quot;localdata&quot;, Totalbytes);
  
                  recdb.insertValues(&quot;records&quot;, cv);
                  recdb.insertCalc();
                  recdb.close();
              }
              cursor1.close();
          }
  
          managedCursor.close();
          calllog.setTransactionSuccessful();
      } catch (Exception e) {
      }
      calllog.endTransaction();
  
      // alertCheck();9
  
      tvpackname = (TextView) findViewById(R.id.packname);
      tvnatbun = (TextView) findViewById(R.id.tvnatmbun);
      tvnatrate = (TextView) findViewById(R.id.tvnatmrate);
      tvintmbun = (TextView) findViewById(R.id.tvinmbun);
      tvintmrate = (TextView) findViewById(R.id.tvintmrate);
      tvsmsbun = (TextView) findViewById(R.id.tvnatsmsbun);
      tvsmsrate = (TextView) findViewById(R.id.tvnatsmsrate);
      tvintsmsrate = (TextView) findViewById(R.id.tvintsmsrate);
      tvdatalbun = (TextView) findViewById(R.id.tvdlocbun);
      tvdatalrate = (TextView) findViewById(R.id.tvdlocrate);
      tvTotal = (TextView) findViewById(R.id.tvtotal);
  
      ArrayList&lt;Object&gt; row;
  
      row = recdb.callrecord(tvnatrate.getText().toString());
  
      tvpackname.setText((String) row.get(0));
      tvnatbun.setText((String) row.get(1));
      tvnatrate.setText((String) row.get(2));
      tvintmbun.setText((String) row.get(3));
      tvintmrate.setText((String) row.get(4));
      tvsmsbun.setText((String) row.get(5));
      tvsmsrate.setText((String) row.get(6));
      tvintsmsrate.setText((String) row.get(7));
      tvdatalbun.setText((String) row.get(8));
      tvdatalrate.setText((String) row.get(9));
      tvTotal.setText((String) row.get(10));
  
      recdb.close();
  
  }
  
  public void alertCheck() {
  
      Alerts al = new Alerts();
  
      ArrayList&lt;Object&gt; alertarr;
  
      alertarr = al.alerttype(toString());
  
      String a = ((String) alertarr.get(0));
      String b = ((String) alertarr.get(2));
  
      int aletot = Integer.parseInt(a);
      int allimit = Integer.parseInt(b);
  
      if (aletot &gt;= (allimit * 50 / 100) &amp;&amp; aletot &lt; (allimit * 75 / 100)) {
  
          AlertDialog.Builder alert1 = new AlertDialog.Builder(this);
          alert1.setTitle(&quot;Warning! Usage - 50%&quot;);
          alert1.setMessage(&quot;Your total usage is now at 50%&quot;);
          alert1.show();
          alert1.setPositiveButton(&quot;OK&quot;, null);
      }
  
      if (aletot &gt;= (allimit * 75 / 100) &amp;&amp; aletot &lt; (allimit * 100 / 100)) {
          AlertDialog.Builder alert2 = new AlertDialog.Builder(this);
          alert2.setTitle(&quot;Warning! Usage - 75%&quot;);
          alert2.setMessage(&quot;Your total usage is now at 75%&quot;);
          alert2.show();
          alert2.setPositiveButton(&quot;OK&quot;, null);
      }
      if (aletot &gt;= (allimit * 100 / 100)) {
          AlertDialog.Builder alert3 = new AlertDialog.Builder(this);
          alert3.setTitle(&quot;Critical - Usage - 100%&quot;);
          alert3.setMessage(&quot;You have now reached your total usage limit!&quot;);
          alert3.show();
          alert3.setPositiveButton(&quot;OK&quot;, null);
  
      }
  
  }
  
   }
  </code></pre>
  <p><strong>The LogCat:</strong></p>
  <pre><code>05-25 18:36:08.715: E/AndroidRuntime(15647): FATAL EXCEPTION: main
  05-25 18:36:08.715: E/AndroidRuntime(15647): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mbf/com.example.mobilebillforecaster.EtiMainScreen}: java.lang.NullPointerException
  05-25 18:36:08.715: E/AndroidRuntime(15647):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
  05-25 18:36:08.715: E/AndroidRuntime(15647):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
  05-25 18:36:08.715: E/AndroidRuntime(15647):    at android.app.ActivityThread.access$600(ActivityThread.java:141)
  05-25 18:36:08.715: E/AndroidRuntime(15647):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
  05-25 18:36:08.715: E/AndroidRuntime(15647):    at android.os.Handler.dispatchMessage(Handler.java:99)
  05-25 18:36:08.715: E/AndroidRuntime(15647):    at android.os.Looper.loop(Looper.java:137)
  05-25 18:36:08.715: E/AndroidRuntime(15647):    at android.app.ActivityThread.main(ActivityThread.java:5039)
  05-25 18:36:08.715: E/AndroidRuntime(15647):    at java.lang.reflect.Method.invokeNative(Native Method)
  05-25 18:36:08.715: E/AndroidRuntime(15647):    at java.lang.reflect.Method.invoke(Method.java:511)
  05-25 18:36:08.715: E/AndroidRuntime(15647):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
  05-25 18:36:08.715: E/AndroidRuntime(15647):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
  05-25 18:36:08.715: E/AndroidRuntime(15647):    at dalvik.system.NativeStart.main(Native Method)
  05-25 18:36:08.715: E/AndroidRuntime(15647): Caused by: java.lang.NullPointerException
  05-25 18:36:08.715: E/AndroidRuntime(15647):    at com.example.mobilebillforecaster.EtiMainScreen.onCreate(EtiMainScreen.java:111)
  05-25 18:36:08.715: E/AndroidRuntime(15647):    at android.app.Activity.performCreate(Activity.java:5104)
  05-25 18:36:08.715: E/AndroidRuntime(15647):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
  05-25 18:36:08.715: E/AndroidRuntime(15647):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
  05-25 18:36:08.715: E/AndroidRuntime(15647):    ... 11 more
  </code></pre>
  <p>thanks,</p>
  <h1>Follow UP to the Question above</h1>
  <p>So I went ahead and added the code to run on an Async task. However, I am currently getting the below error when trying to execute.</p>
  <pre><code>05-30 21:41:10.353: E/AndroidRuntime(7221): FATAL EXCEPTION: AsyncTask #1
  05-30 21:41:10.353: E/AndroidRuntime(7221): java.lang.RuntimeException: An error occured while executing doInBackground()
  05-30 21:41:10.353: E/AndroidRuntime(7221):     at android.os.AsyncTask$3.done(AsyncTask.java:299)
  05-30 21:41:10.353: E/AndroidRuntime(7221):     at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
  05-30 21:41:10.353: E/AndroidRuntime(7221):     at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
  05-30 21:41:10.353: E/AndroidRuntime(7221):     at java.util.concurrent.FutureTask.run(FutureTask.java:239)
  05-30 21:41:10.353: E/AndroidRuntime(7221):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
  05-30 21:41:10.353: E/AndroidRuntime(7221):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
  05-30 21:41:10.353: E/AndroidRuntime(7221):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
  05-30 21:41:10.353: E/AndroidRuntime(7221):     at java.lang.Thread.run(Thread.java:856)
  05-30 21:41:10.353: E/AndroidRuntime(7221): Caused by: java.lang.NullPointerException
  05-30 21:41:10.353: E/AndroidRuntime(7221):     at android.content.ContextWrapper.getContentResolver(ContextWrapper.java:99)
  05-30 21:41:10.353: E/AndroidRuntime(7221):     at com.example.mobilebillforecaster.EtiMainScreen$callDataThread.doInBackground(EtiMainScreen.java:188)
  05-30 21:41:10.353: E/AndroidRuntime(7221):     at com.example.mobilebillforecaster.EtiMainScreen$callDataThread.doInBackground(EtiMainScreen.java:1)
  05-30 21:41:10.353: E/AndroidRuntime(7221):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
  05-30 21:41:10.353: E/AndroidRuntime(7221):     at java.util.concurrent.FutureTask.run(FutureTask.java:234)
  05-30 21:41:10.353: E/AndroidRuntime(7221):     ... 4 more
  </code></pre>
  <p><strong>Coding:</strong></p>
  <p>MainScreen</p>
  <pre><code>package com.example.mobilebillforecaster;
  
  import java.sql.Date;
  import java.text.SimpleDateFormat;
  import java.util.ArrayList;
  
  import android.app.AlertDialog;
  import android.app.TabActivity;
  import android.content.ContentValues;
  import android.content.Context;
  import android.content.Intent;
  import android.database.Cursor;
  import android.database.sqlite.SQLiteDatabase;
  import android.graphics.Color;
  import android.net.TrafficStats;
  import android.net.Uri;
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.provider.CallLog;
  import android.util.Log;
  import android.view.View;
  import android.widget.Button;
  import android.widget.TabHost;
  import android.widget.TextView;
  
  import com.example.mbf.R;
  
  @SuppressWarnings({ &quot;deprecation&quot;, &quot;deprecation&quot; })
  public class EtiMainScreen extends TabActivity {
  
      CallRecords recdb = new CallRecords(this);
      SQLiteDatabase calls;
      Context c = this;
  
      private TextView tvnatbun = null;
      private TextView tvnatrate = null;
      private TextView tvnatsms = null;
      private TextView tvintmbun = null;
      private TextView tvintmrate = null;
      private TextView tvsmsbun = null;
      private TextView tvsmsrate = null;
      private TextView tvintsmsrate = null;
      private TextView tvdatalbun = null;
      private TextView tvdatalrate = null;
      private TextView tvpackname = null;
      private TextView tvTotal = null;
  
      private long mStartRX = 0;
      private long mStartTX = 0;
  
      @SuppressWarnings(&quot;deprecation&quot;)
      protected void onCreate(Bundle Bundle) {
          super.onCreate(Bundle);
          setContentView(R.layout.eti_main_screen);
          
          
          
          initWidgets();
  
          TabHost tabHost = getTabHost();
  
          TabHost.TabSpec spec = getTabHost().newTabSpec(&quot;tag1&quot;);
          spec.setContent(R.id.mainmenu);
          spec.setIndicator(&quot;Main Menu&quot;);
          getTabHost().addTab(spec);
  
          getTabHost().setCurrentTab(0);
  
          spec = getTabHost().newTabSpec(&quot;tag2&quot;);
          spec.setContent(R.id.billhist);
          spec.setIndicator(&quot;Billing History&quot;);
          getTabHost().addTab(spec);
  
          for (int i = 0; i &lt; tabHost.getTabWidget().getChildCount(); i++) {
              TextView tv = (TextView) tabHost.getTabWidget().getChildAt(i)
                      .findViewById(android.R.id.title);
              tv.setTextColor(Color.parseColor(&quot;#FFFFFF&quot;));
          }
  
          TextView tv = (TextView) tabHost.getCurrentTabView().findViewById(
                  android.R.id.title);
          tv.setTextColor(Color.parseColor(&quot;#FFFFFF&quot;));
  
          ((Button) findViewById(R.id.alert))
                  .setOnClickListener(new View.OnClickListener() {
                      public void onClick(View v) {
  
                          Intent localIntent = new Intent(EtiMainScreen.this,
                                  Alerts.class);
                          EtiMainScreen.this.startActivity(localIntent);
                      }
                  });
  
          
          // alertCheck();
          recdb.open();
  
          ArrayList&lt;Object&gt; row;
  
          row = recdb.callrecord(tvnatrate.getText().toString());
  
          tvpackname.setText((String) row.get(0));
          tvnatbun.setText((String) row.get(1));
          tvnatrate.setText((String) row.get(2));
          tvintmbun.setText((String) row.get(3));
          tvintmrate.setText((String) row.get(4));
          tvsmsbun.setText((String) row.get(5));
          tvsmsrate.setText((String) row.get(6));
          tvintsmsrate.setText((String) row.get(7));
          tvdatalbun.setText((String) row.get(8));
          tvdatalrate.setText((String) row.get(9));
          tvTotal.setText((String) row.get(10));
  
          recdb.close();
  
      }
  
      private void initWidgets() {
          tvpackname = (TextView) findViewById(R.id.packname);
          tvnatbun = (TextView) findViewById(R.id.tvnatmbun);
          tvnatrate = (TextView) findViewById(R.id.tvnatmrate);
          tvintmbun = (TextView) findViewById(R.id.tvinmbun);
          tvintmrate = (TextView) findViewById(R.id.tvintmrate);
          tvsmsbun = (TextView) findViewById(R.id.tvnatsmsbun);
          tvsmsrate = (TextView) findViewById(R.id.tvnatsmsrate);
          tvintsmsrate = (TextView) findViewById(R.id.tvintsmsrate);
          tvdatalbun = (TextView) findViewById(R.id.tvdlocbun);
          tvdatalrate = (TextView) findViewById(R.id.tvdlocrate);
          tvTotal = (TextView) findViewById(R.id.tvtotal);
      }
  
      public void alertCheck() {
  
          Alerts al = new Alerts();
  
          ArrayList&lt;Object&gt; alertarr;
  
          alertarr = al.alerttype(toString());
  
          String a = ((String) alertarr.get(0));
          String b = ((String) alertarr.get(2));
  
          int aletot = Integer.parseInt(a);
          int allimit = Integer.parseInt(b);
  
          if (aletot &gt;= (allimit * 50 / 100) &amp;&amp; aletot &lt; (allimit * 75 / 100)) {
  
              AlertDialog.Builder alert1 = new AlertDialog.Builder(this);
              alert1.setTitle(&quot;Warning! Usage - 50%&quot;);
              alert1.setMessage(&quot;Your total usage is now at 50%&quot;);
              alert1.show();
              alert1.setPositiveButton(&quot;OK&quot;, null);
          }
  
          if (aletot &gt;= (allimit * 75 / 100) &amp;&amp; aletot &lt; (allimit * 100 / 100)) {
              AlertDialog.Builder alert2 = new AlertDialog.Builder(this);
              alert2.setTitle(&quot;Warning! Usage - 75%&quot;);
              alert2.setMessage(&quot;Your total usage is now at 75%&quot;);
              alert2.show();
              alert2.setPositiveButton(&quot;OK&quot;, null);
          }
          if (aletot &gt;= (allimit * 100 / 100)) {
              AlertDialog.Builder alert3 = new AlertDialog.Builder(this);
              alert3.setTitle(&quot;Critical - Usage - 100%&quot;);
              alert3.setMessage(&quot;You have now reached your total usage limit!&quot;);
              alert3.show();
              alert3.setPositiveButton(&quot;OK&quot;, null);
  
          }
  
      }
  
      public class callDataThread extends AsyncTask&lt;String, Integer, String&gt; {
  
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
          }
  
          // callRecordsHelper recdb =
          // callRecordsHelper.getDBAdapterInstance(EtiMainScreen.this);
          @Override
          protected String doInBackground(String... params) {
              // TODO Auto-generated method stub
  
              Uri SMSsentQuery = Uri.parse(&quot;content://sms/sent&quot;);
  
              Cursor cursor1 = getContentResolver().query(SMSsentQuery, null,
                      null, null, null);
  
              Cursor managedCursor = getContentResolver().query(
                      android.provider.CallLog.Calls.CONTENT_URI, null, null,
                      null, null);
  
              mStartRX = TrafficStats.getMobileRxBytes();
              mStartTX = TrafficStats.getMobileTxBytes();
              long Totalbytes = mStartRX + mStartTX;
  
              Log.v(&quot;&quot;, Long.toString(mStartRX));
              Log.v(&quot;&quot;, Long.toString(mStartTX));
              Log.v(&quot;&quot;, Long.toString(Totalbytes));
              int usage = Long.bitCount(Totalbytes) / 1024;
  
              recdb.open();
              // calls.beginTransaction();
              // try {
              if (managedCursor != null &amp;&amp; managedCursor.moveToFirst()) {
                  do {
  
                      String callNumber = managedCursor.getString(managedCursor
                              .getColumnIndex(CallLog.Calls.NUMBER));
                      String callType = managedCursor.getString(managedCursor
                              .getColumnIndex(CallLog.Calls.TYPE));
                      String callDur = managedCursor.getString(managedCursor
                              .getColumnIndex(CallLog.Calls.DURATION));
                      int dateId = managedCursor
                              .getColumnIndex(android.provider.CallLog.Calls.DATE);
  
                      long callDate = managedCursor.getLong(dateId);
                      SimpleDateFormat datePattern = new SimpleDateFormat(
                              &quot;yyyy-MM-dd HH:mm&quot;);
                      String date_str = datePattern.format(new Date(callDate));
  
                      int dircode = Integer.parseInt(callType);
                      float value = Float.parseFloat(callDur);
                      float callDuration = value / 60;
  
                      // calls.yieldIfContendedSafely();
                      ContentValues cv = new ContentValues();
  
                      if (dircode == CallLog.Calls.OUTGOING_TYPE) {
                          if (callNumber.startsWith(&quot;00971&quot;)
                                  || callNumber.startsWith(&quot;05&quot;)
                                  || callNumber.startsWith(&quot;04&quot;)
                                  || callNumber.startsWith(&quot;03&quot;)
                                  || callNumber.startsWith(&quot;02&quot;)) {
  
                              cv.put(&quot;cnatdur&quot;, callDuration);
                          } else {
                              cv.put(&quot;cintdur&quot;, callDuration);
                          }
                      }
                      int natsms = 0, intsms = 0;
                      if (cursor1 != null &amp;&amp; cursor1.moveToFirst()) {
                          do {
                              String address = cursor1.getString(cursor1
                                      .getColumnIndex(&quot;address&quot;));
  
                              if (address.startsWith(&quot;009-71&quot;)
                                      || address.startsWith(&quot;(05&quot;)
                                      || address.startsWith(&quot;05&quot;)) {
  
                                  natsms++;
                                  cv.put(&quot;natsms&quot;, natsms);
  
                              } else {
                                  intsms++;
  
                                  cv.put(&quot;intsms&quot;, intsms);
                              }
  
                              cv.put(&quot;cdate&quot;, date_str);
                              cv.put(&quot;localdata&quot;, usage);
  
                              recdb.insertValues(&quot;records&quot;, cv);
                              recdb.insertCalc();
                              recdb.close();
                          } while (cursor1.moveToNext());
                          cursor1.close();
                      }
                  } while (managedCursor.moveToNext());
                  managedCursor.close();
              }
  
              // calls.setTransactionSuccessful();
              // } finally {
              // calls.endTransaction();
              // }
              return null;
          }
  
          @Override
          protected void onPostExecute(String result) {
              super.onPostExecute(result);
          }
      }
  }
  </code></pre>
  <p>Any Assistance will be very much appreciated.</p>
  <p>thanks</p>