Hello, I'm all trying to read a json file with retrofit and then save it in sqllite, but when the project is implemented the app closes
I have the Customers class, they are more fields but that's how the structure goes, with its respective set-to-get.
@SerializedName("CMA_CODIGO")
@Expose
private String cMACODIGO;
@SerializedName("CMA_TIPO_CLIENTE")
@Expose
private String cMATIPOCLIENTE;
@SerializedName("CMA_NOMBRE")
@Expose
private String cMANOMBRE;
The interface is like this.
public interface RetrofitClientesArray {
/*
* Retrofit get annotation with our URL
* And our method that will return us details of student.
*/
@GET("cspm/clientes.json")
Call<List<clientes>> getClientesDetails();
}
In the main is the function to read like this.
private void getRetrofitClientes(){
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://tucuenca.com/")
.addConverterFactory(GsonConverterFactory.create())
.build();
RetrofitClientesArray service = retrofit.create(RetrofitClientesArray.class);
Call<List<clientes>> call = service.getClientesDetails();
call.enqueue(new Callback<List<clientes>>() {
@Override
public void onResponse(Call<List<clientes>> call, Response<List<clientes>> response) {
try{
Log.d("Exito ", "Leyendo");
}catch (Exception e){
Log.d("onResponse", "There is an error");
e.printStackTrace();
}
}
@Override
public void onFailure(Call<List<clientes>> call, Throwable t) {
Log.d("onFailure", t.toString());
showLoginError(t.toString());
}
});
}
When I run the logcat it gives me this message
04-19 13:12:59.778 32209-32209/com.---.ventas3.spm I/art: Late-enabling -Xcheck:jni 04-19 13:12:59.778
32209-32209 / com .---. sales3.spm I / art: Reinit property: dalvik.vm.checkjni = false 04-19 13: 12: 59.907 32209-32209 /? W / System: ClassLoader referenced unknown path: /data/app/com.---.sales3.spm-2/lib/arm64 04-19 13: 12: 59.908 32209-32209 /? W / art: JIT profile information will not be recorded: profile file does not exits. 04-19 13: 12: 59.915 32209-32209 /? I / InstantRun: starting instant run server: is main process 04-19 13: 12: 59.934 32209-32209 /? I / HwCust: Constructor found for class android.app.HwCustActivityImpl 04-19 13: 12: 59.948 32209-32209 /? I / HwCust: Constructor found for class android.app.HwCustHwWallpaperManagerImpl 04-19 13: 12: 59.961 32209-32209 /? W / art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter (android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff $ Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable 04-19 13: 13: 00.142 32209-32209 /? I / HwSecImmHelper: mSecurityInputMethodService is null 04-19 13: 13: 00.145 32209-32209 /? I / HwPointEventFilter: support AFT 04-19 13: 13: 00.154 32209-32271 /? I / Process: Sending signal. PID: 32209 SIG: 9