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 - Old question containing my code
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.
Edit -
I get a small exeption while trying to initilise Gson - String json = gson.toJson(Record); . Can you take a look please -
public ArrayList<Record> getAllRecordsArray() {
ArrayList<Record> localList = new ArrayList<Record>();
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);