Avoid harcode map api key in java and Layout xml file

Put your problem here if it does not fit any of the other categories.

Avoid harcode map api key in java and Layout xml file

Postby androidUser » Sun Apr 19, 2009 6:13 pm

How to avoid harcode the value of map api key in java and layout xml file ?

Any design pattern ?
androidUser
Junior Developer
Junior Developer
 
Posts: 24
Joined: Sun Apr 05, 2009 1:08 pm

Top

Postby alpesh_harsoda » Wed Apr 29, 2009 2:24 pm

can u explain,what u want to do?
Regards,
Alpesh Patel,
Logistic Infotech
http://www.logisticinfotech.com
User avatar
alpesh_harsoda
Senior Developer
Senior Developer
 
Posts: 106
Joined: Sat Sep 20, 2008 12:35 pm
Location: Rajkot,Gujarat(India)

Postby androidUser » Wed Apr 29, 2009 5:54 pm

Thanks for your mail.
To display the graph, we need to provide our map api key in two ways,
1) layout xml file
2) java code


My question is how to avoid hardcode the map api key ?
For example , like properites file which we can define in one common place.
So that if you want to run in other machine, we can change in one common place which we can avoid changing in all the places.
androidUser
Junior Developer
Junior Developer
 
Posts: 24
Joined: Sun Apr 05, 2009 1:08 pm

Postby alpesh_harsoda » Thu Apr 30, 2009 6:54 am

HI,
you can put the key on preferences and get that using Context.getSharedPreferences().
Regards,
Alpesh Patel,
Logistic Infotech
http://www.logisticinfotech.com
User avatar
alpesh_harsoda
Senior Developer
Senior Developer
 
Posts: 106
Joined: Sat Sep 20, 2008 12:35 pm
Location: Rajkot,Gujarat(India)

Postby androidUser » Wed May 06, 2009 6:51 am

Using Context.getSharedPreferences() ? Any examples plz.

Can i use properties file (MAP_API_KEY=<MYKEY>) in android applications. So that i can get the value using java.util.ResourceBundle in java code ?
androidUser
Junior Developer
Junior Developer
 
Posts: 24
Joined: Sun Apr 05, 2009 1:08 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 9 guests