retrofit instance done

This commit is contained in:
2023-12-20 10:50:21 +02:00
parent 0b45765f4a
commit 62e73fb0de

View File

@@ -0,0 +1,31 @@
package com.example.myapp_1.DB;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class RetrofitClient {
private static Retrofit retrofit;
//Define the base URL//
private static final String BASE_URL = "https://localhost:8080";
//Create the Retrofit instance//
public static Retrofit getRetrofitInstance() {
if (retrofit == null) {
retrofit = new retrofit2.Retrofit.Builder()
.baseUrl(BASE_URL)
//Add the converter//
.addConverterFactory(GsonConverterFactory.create())
//Build the Retrofit instance//
.build();
}
return retrofit;
}
}