How to save my data that I have stored in SQLITE to remote MYSQL (Volley)?

1

I'm trying to decipher and the truth is that I'm already very burned and I can not figure out how to store my SQLITE list (cart of articles and prices) in a remote MYSQL database (I'm working with volley);

The theme is like this first I retrieve my SQLITe data and store it in a list:

    private List<PedidosBean> recuperaListaSQLite() {
    AdminSQLiteOpenHelper admin = new AdminSQLiteOpenHelper(getApplicationContext(), "pedidos", null, 1);
    SQLiteDatabase bd = admin.getReadableDatabase();
    Cursor cursor = bd.rawQuery("SELECT nombre_art, precio_art, codigo_art, cantidad_art FROM pedidos", null);

    DecimalFormat df = new DecimalFormat("#.00");
    if (cursor.moveToFirst()) {
        do {
            PedidosBean articulos = new PedidosBean();
            articulos.setNombre_art(cursor.getString(0));
            articulos.setPrecio_art(cursor.getDouble(1));
            articulos.setCodigo_art(cursor.getInt(2));
            articulos.setCantidad_art(cursor.getInt(3));

            listaSQLite.add(articulos);

        } while (cursor.moveToNext());
    }


    bd.close();

    return listaSQLite;

}

Then I do not know what to do to take it to mysql ... I convert it into JsonArray? I swear I do not realize. please a little help?

    
asked by Lucas Jose Sola 28.11.2018 в 16:40
source

1 answer

0

After breaking the coconut (this is the nice thing about the programming) I found the solution with the library GSON .. so retrieve the data from sqlite store it in a List object and with the fabulous GSON turned it into json to send it to the web service.

    
answered by 30.11.2018 / 21:23
source