From 62e73fb0de8883095b1c93c2eea787626247540d Mon Sep 17 00:00:00 2001 From: linlyboi Date: Wed, 20 Dec 2023 10:50:21 +0200 Subject: [PATCH] retrofit instance done --- .../example/myapp_1/DB/RetrofitClient.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 app/src/main/java/com/example/myapp_1/DB/RetrofitClient.java diff --git a/app/src/main/java/com/example/myapp_1/DB/RetrofitClient.java b/app/src/main/java/com/example/myapp_1/DB/RetrofitClient.java new file mode 100644 index 0000000..d938502 --- /dev/null +++ b/app/src/main/java/com/example/myapp_1/DB/RetrofitClient.java @@ -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; + } +} \ No newline at end of file