I want to send data to server with retrofit
library .
And I want to know how to resend my data to server when network is back
public void sendPost(String title, String body) {
mpiService.savePost(title, body, 1).enqueue(new Callback<Post>() {
@Override
public void onResponse(Call<Post> call, Response<Post> response) {
if(response.isSuccessful()) {
showResponse(response.body().toString());
Log.i(TAG, "post submitted to API." + response.body().toString());
}
}
@Override
public void onFailure(Call<Post> call, Throwable t) {
Log.e(TAG, "Unable to submit post to API.");
}
});
}
I know I should create database and use broadcast
to check status
I want to know how I can store data to database with data field or jSONArray
?
Please help me with database creation