Yunus Sımsıkı
Yunus Sımsıkı

Reputation: 55

Android urlConnection setUseCache(false) doesnt work

I m using this code at the moment. It works perfectly when device doesnt have internet(It doesnt use cache) but when I update the txt file, it doesnt update it in app, it uses the previous one.

URL url = new URL("http://www.myhost.com/ygs/somefile.txt");
                    URLConnection urlConnection = url.openConnection();
                    urlConnection.setUseCaches(false);

What should I do?

Upvotes: 0

Views: 280

Answers (1)

Hasanaga
Hasanaga

Reputation: 1098

Add a random number or a timestring to the querystring URL

url = new URL("http://www.myhost.com/ygs/somefile.txt?r="+Math.random());

Upvotes: 3

Related Questions