Presentation is loading. Please wait.

Presentation is loading. Please wait.

Purdue Pride 4.7.10 Joe Gutierrez Tung Ho Janam Jhaveri 4/7/2010Purdue Pride1.

Similar presentations


Presentation on theme: "Purdue Pride 4.7.10 Joe Gutierrez Tung Ho Janam Jhaveri 4/7/2010Purdue Pride1."— Presentation transcript:

1 Purdue Pride 4.7.10 Joe Gutierrez Tung Ho Janam Jhaveri 4/7/2010Purdue Pride1

2 Timeline 7 weeks March 10 th : Widget, RSS tutorials March 24 th : RSS Feed April 7 th : SQL Lite Database (currently working on) April 21 st : Widget April 28 th : Work off any loose ends 4/7/2010Purdue Pride2

3 Milestones Website with RSS feed is set up (3.3.10) Basic widget displays hard-coded text (3.10.10) Successfully store and recall data from SQL Lite with an application (3.24.10) Successfully retrieve and display RSS feed onto view (4.1.10) 4/7/2010Purdue Pride3

4 Database Code public class PrideDB { private static final String FEEDS_TABLE = "feeds"; private static final String DATABASE_NAME = "pride"; private static SQLiteDatabase db; public PrideDB(Context ctx) { db = ctx.openOrCreateDatabase(DATABASE_NAME, 0, null); //API change } 4/7/2010Purdue Pride4

5 Database Code public static boolean insertItem(String title, String description) { ContentValues values = new ContentValues(); values.put("title", title); values.put("description", description); return(db.insert(FEEDS_TABLE, null, values) > 0); } public boolean deleteItem(Long feedID) { return(db.delete(FEEDS_TABLE, "feed_id=" + feedID.toString(), null) > 0); } public static List getItems() { ArrayList feeds = new ArrayList (); try { Cursor c = db.query(FEEDS_TABLE, new String[] {"feed_id", "title", "description"}, null, null, null, null, null); int numRows = c.getCount(); //API change for( int i =0; i < numRows; ++i) { RSSItem item = new RSSItem(); item.feedId = c.getLong(0); item.title = c.getString(1); item.description = c.getString(2); feeds.add(item); c.moveToNext(); //API change } 4/7/2010Purdue Pride5

6 Database Code catch (SQLException e) { Log.e("PurduePride",e.toString()); } return feeds; } public static RSSItem getItem() { RSSItem item = new RSSItem(); try { Cursor c = db.query(FEEDS_TABLE, new String[] {"feed_id", "title", "description"}, null, null, null, null, null); item.feedId = c.getLong(0); //item.title = c.getString(1); //item.description = c.getString(2); } catch (SQLException e) { Log.e("PurduePride",e.toString()); } return item; } } 4/7/2010Purdue Pride6

7 RSS Handler if (item.title != null) { PrideDB.insertItem(item.title, item.description); item.title = null; item.description = null; /*itemsAdded++; if (itemsAdded >= ARTICLES_LIMIT) { throw new SAXException(); } */ } 4/7/2010Purdue Pride7

8 Pride RSS 4/7/2010Purdue Pride8 handler.setContext(this);

9 Widget XML 4/7/2010Purdue Pride9 //XML file with some metadata about the widget. "Called" in main Widget Java file http://cobweb.ecn.purdue.edu/~vipfor/index.html

10 Next Task 4/7/2010Purdue Pride10 April 7 th : Have RSS feed interacting with database (in Progress) April 21 st : Display RSS feed onto Widget


Download ppt "Purdue Pride 4.7.10 Joe Gutierrez Tung Ho Janam Jhaveri 4/7/2010Purdue Pride1."

Similar presentations


Ads by Google