Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to store api-urls in android app?

I want to store the api urls somewhere , if I require I can change easily. If I keep in my server still I need url to access server which requires authentication. If I store in assets then there is a chance of stealing it by decompiling the apk. I don't want to hardcode urls in code or String.xml. Please suggest the best way where I can keep safe and change url easily. Thanks !!

like image 792
Mukesh Avatar asked May 31 '16 09:05

Mukesh


1 Answers

The best way in your case is store api url's in server because you can change them later. You'd create one url to fetch your api urls. Build your app based on an architecture like this.

[
    {url: "/user/login", type:"login"},
    {url: "/user/register", type:"register"}
]

And don't forget anyone can see your server urls. It even doesn't have to decompiled because there are tools to watch device's network traffic:

  • Wireshark
  • Packet Capture
like image 197
Ozgur Avatar answered Oct 22 '22 18:10

Ozgur