I'm new to Android development and I've started creating this app where I read an XML feed and list the contents. But even though the feed changes I still get the same data displayed. Although over night the cache seemed to clear itself. I would like to force reading of the feed each time I start my app. I tried the methods described here How to clear cache Android but it didn't help.
My guess is that I would have to do it onCreate in my main activity (at least that's what I have tried so far).
Can anyone point me in the right direction?
Thanks in advance :-)
Here are some code snippets.
From my activity:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_game);
deleteCache(this);
new ReadLeagueXml().execute();
}
deleteCache is the method from the other thread I linked to.
Then in my doInBackground I have
InputStream inputStream = new URL(xmlURL).openStream();
if (inputStream != null) {
list = parse(inputStream);
}
And finally in my onPostExecute:
ListView matchListView = (ListView)findViewById(R.id.match_list);
List<String> matchArray = new ArrayList<String>();
for (int i = 0; i < matches.size(); i++) {
matchArray.add(matches.get(i).HomeTeam + " - " + matches.get(i).AwayTeam);
}
matchArray.toArray();
matchesArrayAdapter = new MatchListAdapter(ListGameActivity.this, matches);
matchListView.setAdapter(matchesArrayAdapter);