title: Cursor window allocation of 2048 kb failed running with background service (runnable)
body: <p>i have problem with get data from SQLite <em>Cursor window allocation of 2048 kb failed</em> using Thread background service</p>
  
  <p>but if i run <strong>List branchList= DBTransaction.BranchList();</strong> without Thread background service, this function is working normally</p>
  
  <p><strong>MyService.Java</strong></p>
  
  <pre><code>public int onStartCommand(Intent intent, int flags, int startId) {
      Log.i(TAG, "Service onStartCommand");
      new Thread(new Runnable() {
          @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
          @Override
          public void run() {
              while(true)
              {
                  List&lt;Branch&gt; branchList= DBTransaction.BranchList();
                  if (branchList.size() &lt; 0)
                      getBranch(); //get branch using volley get data from web service
  
                  try {
                      Thread.sleep(10000);
                  } catch (InterruptedException e) {
                      e.printStackTrace();
                  }
              }
          }
      }).start();
      return START_STICKY;
  }
  </code></pre>
  
  <p><strong>SQLite GetData</strong></p>
  
  <pre><code>public List&lt;Branch&gt; BranchList(){
      List&lt;Branch&gt; branchList = new ArrayList&lt;Branch&gt;();
      String selectQuery = "SELECT * FROM " + TABLE_BRANCH;
  
      SQLiteDatabase db = getReadableDatabase();
      Cursor cursor = null;
      try {
          cursor = db.rawQuery(selectQuery, null);
          if (cursor.moveToFirst()){
              do{
                  Branch branch = new Branch();
                  branch.setID(cursor.getString(0));
                  branch.setName(cursor.getString(1));
                  branch.setCode(cursor.getString(2));
  
                  branchList.add(branch);
              }while (cursor.moveToNext());
          }
      }finally { 
           if(cursor != null)
           cursor.close();
      }
      return branchList;
  }
  </code></pre>
  
  <p><strong>Error result from android monitor</strong></p>
  
  <pre><code>E/Volley: [10497] NetworkDispatcher.run: Unhandled exception android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. # Open Cursors=8 (# cursors opened by this proc=8)
                                                  android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. # Open Cursors=8 (# cursors opened by this proc=8)
  </code></pre>