title: Android SQlite to json
body: <p>I have some data stored inside SQlite at my android application and I want to export it into json file and send it to a server via post HTTP. 
  You can actually see my code in this link - <a href="https://stackoverflow.com/questions/27692158/android-database-sqlite-sqliteexception-near-create-record-table">Old question containing my code</a></p>
  
  <p>After searching the web, I'm only finding samples of doing it the other way around (from json to sqlite). I'll be happy to receive some help/push to the right direction.</p>
  
  <p>Edit -</p>
  
  <p>I get a small exeption while trying to initilise Gson - String json = gson.toJson(Record);
  . Can you take a look please - </p>
  
  <pre><code>public ArrayList&lt;Record&gt; getAllRecordsArray() {
          ArrayList&lt;Record&gt; localList = new ArrayList&lt;Record&gt;();
  
          String selectQuery = "SELECT * FROM " + TABLE_RECORD;
  
          SQLiteDatabase db = this.getReadableDatabase();
          Cursor cursor = db.rawQuery(selectQuery, null);
  
          //Loops through all rows and adds them to the local list
          if(cursor.moveToFirst())
          {
              do {
                  //Get record information
                  Record record = new Record();
                  record.setpLat(cursor.getDouble(0));
                  record.setpLong(cursor.getDouble(1));
                  record.setpAcc(cursor.getFloat(2));
                  record.setpTime(cursor.getLong(2));
                  //Add record  to list
                  localList.add(record);
              } while (cursor.moveToNext());
          }
  
          return localList;
      }
  
      Gson gson = new Gson();
      String json = gson.toJson(Record);
  </code></pre>