Quantcast
Channel: How to store RSS feeds in Android? - Stack Overflow
Viewing all articles
Browse latest Browse all 2

How to store RSS feeds in Android?

$
0
0

I want to cache RSS feeds into SQLite database to improve performance of the app.
I am only concerned with the very basic of the RSS feed namely the title, description, URL guid and the pubDate. As of now, I can process them and store them into Vector<Feed> where Feed is my custom class.

There area few things which I find mind-boggling as a newbie to Android.
Say I have feed items whose titles are as below:

1. Cat Kills the Dog2. Curosity Killed the Cat in Revenge3. Y U NO leave Cat alone ?  

In the first run, getting the row count of the table will return zero which means that I have to add all the feeds into the database. No problems.
The problem comes when the feeds are updated. Here is the updated feed:

*. Quick Brown Fox Jumps Over The Lazy Dog. Dog Dies.1. Cat Kills the Dog2. Curosity Killed the Cat in Revenge3. Y U NO leave Cat alone ?

The logic is:
1. Start parsing the RSS feeds.
2. Read the title of the newly fetched RSS feed.
3. Does it match the title of the first row of the data base?
3.1. No, then keep parsing and add this feed to the database.
3.2. Yes, then stop parsing and add this feed to the database.

Problem is, the row added now will be the LAST ROW of the table while it should be, as in the RSS XML feed, the first row so that subsequent comparison becomes easier.

The thing is to maintain the order of rows similar to that in the feed XML.
How do I maintain that order ?

Or, is there a better way to organize and store the feeds ?


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images