I am using an API within my app. I currently manage the API key from a java interface
public interface APIContract {
//The API KEY MUST NOT BE PUBLISH. It is possible to generate a new one for free from www.themoviedb.org
//Remove before commit !!!
String API_KEY = "abcdefghijklmnopqrstuvwxyz";
/...
}
This do the job. I can access the key using APIContract.API_KEY
, but as you can see in the comment this is not safe if I use git and a public repository (I am not suppose to publish this key).
So here is my question : is it possible to move this key in another place which I can easily access from my app but which will not be committed ?
I found this thread which use gradle to store the key, but I need to commit the build.gradle
file so it does not do the job.
Does someone know how to solve this problem ? I did not find similar problem in stackoverflow but maybe I missed something
EDIT
I love the idea of moving the key outside any java code because other people (maybe non technical people) can easily manage their own key. I was thinking about using a gradle file like settings.gradle
.