问题
For starters, I am not a programmer, my wife is making me learn how to program for Android because she wants me to make her some apps to use around the house.
I have a basic app that loads a JPG into a WebView window. I read that in order to help manage caching it's a good idea to add a timestamp to a URL.
I am not sure how to add a Timestamp into the URL.
This is what I have now:
mWebView.loadUrl("http://www.website.com/webviewimage.jpg"+"?123");
I plan to replace the "?123" with the Timestamp, but I'm not sure how to type this in. I have this in the beginning of my code so hopefully, I'm thinking I'm halfway there.:
import java.sql.Timestamp;
Thank you so much for your help.
Cheers,
Pat
回答1:
This will put the current time in milliseconds on to the end of your URL.
mWebView.loadUrl("http://www.website.com/webviewimage.jpg?" + System.currentTimeMillis());
来源:https://stackoverflow.com/questions/5944632/android-add-timestamp-to-url-for-webview