My app works as a client for different servers, which means that I have to deal with a changing api base url. The base url is set once at the app start by the user, and then stays the same during runtime. Normally I would use SharedPreferences to load app data, but therefore an ApplicationContext is needed.
What is the best practice for this use case?
Currently my Retrofit Service class looks like this:
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class RetrofitService {
private static Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://testtapi.org/v2/")
.addConverterFactory(GsonConverterFactory.create())
.build();
public static <S> S cteateService(Class<S> serviceClass) {
return retrofit.create(serviceClass);
}
}