https://wiki.cdot.senecacollege.ca/w/api.php?action=feedcontributions&user=Ladanzahir&feedformat=atomCDOT Wiki - User contributions [en]2024-03-28T10:23:06ZUser contributionsMediaWiki 1.30.0https://wiki.cdot.senecacollege.ca/w/index.php?title=Planet_CDOT_Feed_List&diff=91710Planet CDOT Feed List2012-11-30T15:42:08Z<p>Ladanzahir: /* Feeds */</p>
<hr />
<div>{{Admon/important|Wiki email problems have been fixed!|If you requested an account but did not receive an email response, please see the [[Wiki email issues - September 2012|wiki email issues]] page.}}<br />
<br />
= Introduction =<br />
<br />
Seneca students and faculty working on open source related projects and research, as well as some faculty, students, and researchers from other institutions, use [http://zenit.senecac.on.ca/~chris.tyler/planet/ Planet CDOT] to aggregate their blogs. This page contains the information about who is blogging in [http://www.planetplanet.org/ Planet Feed Reader format] and serves as the feed configuration for the planet.<br />
<br />
If you do not have an existing blog, you can open a free account at [http://wordpress.com/ Wordpress.com] or [https://www.blogger.com/ Blogger.com] or you can set up your own blog software such as [http://www.s9y.org Serendipity].<br />
<br />
'''Note:''' Additions to the feed list will not take effect until they are merged into the Planet configuration, which is an automatic process scheduled at regular intervals. If you add a feed and do not see it picked up in the Planet within three hours, please check your feed entry carefully and then contact [[User:Chris Tyler|Chris Tyler]] .<br />
<br />
= Requirements =<br />
<br />
* Blog postings fed to the planet must conform to the [[Blog Guidelines]].<br />
* Feeds that are inactive for a significant period of time may get deleted from this list.<br />
<br />
= Using a Tagged/Category Feed =<br />
<br />
A tagged or category feed includes only articles that are tagged with particular keywords or placed in a particular topic category. This can be useful for sending only selected posts to the planet.<br />
<br />
These are the URL formats for tagged or category feeds on popular blogging services/software:<br />
<br />
* [http://www.wordpress.com Wordpress]: <code><nowiki>[http://</nowiki>''blog-user-name''.wordpress.com/category/''category-name''/feed/]</code><br />
* [http://blogger.com Blogger]: <code><nowiki>[http://</nowiki>''blog-user-name''.blogspot.com/feeds/posts/default/-/''category-name'']</code><br />
* [http://s9y.org Serendipity]: <code><nowiki>[http://</nowiki>''blog-main-url''/index.php?/feeds/categories/''cateogrynumber''-''categoryname'']</code><br />
<br />
= Feed Info Format =<br />
<br />
You can add your blog's [http://en.wikipedia.org/wiki/RSS_(file_format) RSS feed] at the end of the list below by specifying the following:<br />
<br />
# The URL to your blog's open source Atom or [http://en.wikipedia.org/wiki/RSS_(file_format) RSS Feed] (i.e., a category or tag). NOTE: Please do not put the URL to your blog -- use the URL for your feed. Please do not use the feed for your entire blog (unless your blog contains only open source-related postings). We only want open source related content.<br />
# Your name as you want it to appear in the list of names for the planet<br />
# Optionally, a URL to a [http://en.wikipedia.org/wiki/Hackergotchi hackergotchi] ([http://wouterverhelst.livejournal.com/21322.html how to]). Your picture should be an 65x85 PNG with a transparent background.<br />
<br />
= Feeds =<br />
<br />
<pre><br />
<br />
[https://jamaljalali.wordpress.com]<br />
name= Jamal Jalali<br />
<br />
[http://m0le-security.blogspot.com/feeds/posts/default]<br />
name=Tin Gia Lam<br />
<br />
[http://aadavis1.blogspot.ca/feeds/posts/default]<br />
name=Alexander Davis<br />
<br />
[http://thevakaran.wordpress.com/category/open-source/feed/]<br />
name=Thevakaran Virutthasalam<br />
<br />
[http://kyu6.wordpress.com/feed/]<br />
name=Keren Yu <br />
<br />
[http://chestersbr600.wordpress.com/]<br />
name=VicChester Ngo<br />
<br />
[http://cty6sbr600.wordpress.com/feed/]<br />
name=Kalpaniya Parmar<br />
<br />
[http://cty6.wordpress.com/feed/]<br />
name=Luis Fuentes<br />
<br />
[http://sbr600.wordpress.com/2012/01/26/build-from-source/]<br />
name=Rachit Chaudhary (DJ)<br />
<br />
[http://sbr600.wordpress.com/2012/01/26/introduction/]<br />
name=Rachit Chaudhary (DJ)<br />
<br />
[http://craigcain.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Craig Cain<br />
<br />
<br />
[http://i0x777.wordpress.com/feed/]<br />
name=Nikhil Sharma<br />
<br />
[http://wolfleaderslair.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Dennis Villasenor<br />
<br />
[http://gkrilov.com/category/open-source/feed/]<br />
name=Greg Krilov<br />
<br />
[http://rubensmaximus.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Rubens Maximus (GameArtist)<br />
<br />
[http://mschranz.wordpress.com/category/open_source/feed/]<br />
name=Matthew Schranz<br />
<br />
[http://fedoraisfun.wordpress.com/category/open_source/feed/]<br />
name=Alan Lau<br />
<br />
[http://www.spectakular.com/category/open-source/feed/]<br />
name=Simon Jung<br />
<br />
[http://james.boelen.ca/category/open_source/feed/]<br />
name=James Boelen<br />
<br />
[http://jbuckley.ca/category/open-source/feed/]<br />
name=Jon Buckley<br />
<br />
[http://mbrzuzy.wordpress.com/category/open-source/feed/]<br />
name=Marcin Brzuzy<br />
<br />
[http://ben1amin.wordpress.com/category/seneca/feed/]<br />
name=Benjamin Chalovich<br />
<br />
[http://edghardest1.wordpress.com/category/open-source-topics/feed/]<br />
name=Ed Arvelaez<br />
<br />
[http://www.ashkansotoudeh.com/?tag=coding-2&feed=rss2]<br />
name=Ashkan Sotoudeh<br />
<br />
[http://dboddie46.wordpress.com/category/SBR600A/feed/]<br />
name=Derrick Boddie<br />
<br />
[http://aali83.blogspot.com/feeds/posts/default/-/oop344]<br />
name=Ahmad Ali<br />
<br />
[http://gr8can8dian.wordpress.com/category/sbr600/feed/]<br />
name=Lorin Soura<br />
<br />
[http://kirtonmike.wordpress.com/category/SBR600/feed/]<br />
name=Mike Kirton<br />
<br />
[http://fuzzux.wordpress.com/category/SBR600/feed/]<br />
name=Tim Furzer<br />
<br />
[http://nageyi.wordpress.com/feed/]<br />
name=Faisal Nageyi<br />
<br />
[http://KrazyDre.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Andrei Artamonov<br />
<br />
[http://mjcorsame.wordpress.com/feed/]<br />
name=Michael John Corsame<br />
<br />
[http://msbreezy12.wordpress.com/category/SBR/feed/]<br />
name=Chantell Mcintosh<br />
<br />
# Disabled 2011-04-28 - empty blog<br />
#[http://mrtait1.blogspot.com/feeds/posts/default/-/oop344]<br />
#name=Matthew Tait<br />
<br />
[http://sbr600cabbott.blogspot.com/feeds/posts/default]<br />
name=Chris Abbott<br />
<br />
[http://kopay.wordpress.com/category/sbr600-win2011/feed]<br />
name=Pirathapan Sivalingam<br />
<br />
[http://mysnogorodsky.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Marina Ysnogorodsky<br />
<br />
[http://asa.veryusefulinfo.com/?feed=rss2]<br />
name=Ali Samimi<br />
<br />
# Disabled 2011-04-28 - empty blog<br />
#[http://coreyangus.blogspot.com/feeds/posts/default/-/oop344]<br />
#name = Corey Angus<br />
<br />
[http://wsong18.blogspot.com/feeds/posts/default/-/open-source]<br />
name=Wei Song<br />
<br />
[http://davidsosd60020102blog.blogspot.com/feeds/posts/default]<br />
name=David Takasaki<br />
<br />
[http://zwang98.blogspot.com/feeds/posts/default]<br />
name=Joe Wang<br />
<br />
[http://sbr700.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Jonathan Deni<br />
#face=https://techontherun.sslpowered.com/techontherun.ca/jonthumb.png<br />
<br />
[http://dgilloch.blogspot.com/feeds/posts/default]<br />
name=Daniel Gilloch<br />
<br />
[http://jmchen11.wordpress.com/feed/]<br />
name=Jianming Chen<br />
<br />
[http://paulfedora.wordpress.com/tag/cdot/feed/]<br />
name=Paul Whalen<br />
<br />
[http://maxamaxim.wordpress.com/tag/cdot/feed/]<br />
name=Masihul Abed <br />
<br />
[http://dmchisho.wordpress.com/feed/]<br />
name=David Chisholm<br />
<br />
[http://pokerface3.blogspot.com/feeds/posts/default/-/SBR?alt=rss]<br />
name=David Cabral<br />
<br />
[http://zbhuang1.blogspot.com/feeds/posts/default/-/open%20source]<br />
name=Zhibin Huang<br />
<br />
[http://sidsbr.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Sadiki Latty<br />
<br />
[http://orel60.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Or-el Mousaffi<br />
<br />
[http://aryafarzan.wordpress.com/category/OOP344/feed/]<br />
name=Arya Farzan<br />
<br />
[http://dsventura.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Dan Ventura<br />
<br />
[http://chrisdecairos.ca/category/open-source/feed]<br />
name=Christopher DeCairos<br />
<br />
[http://acfunktron.blogspot.com/feeds/posts/default]<br />
name=Anton Chan<br />
<br />
[http://adaniel3.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Arlene Daniel<br />
<br />
[http://tyrant911-processingdotjs.blogspot.com/feeds/posts/default/-/processing.js]<br />
name=Alex Londono<br />
<br />
<br />
[http://ausleyj.blogspot.com/feeds/posts/default]<br />
name=Ausley Johnson<br />
<br />
[http://arminoop344.blogspot.com/feeds/posts/default]<br />
name=Armin Kumarshellah<br />
<br />
[http://cloudscorpion.blogspot.com/feeds/posts/default/-/open-source]<br />
name=Joseph Hughes<br />
<br />
[http://travisrawn.blogspot.com/feeds/posts/default]<br />
name=Travis Rawn<br />
<br />
[http://jmpiltz.blogspot.com/feeds/posts/default]<br />
name=Jonathan Piltz<br />
<br />
[http://andrewgrimo.wordpress.com/category/open-source/feed/]<br />
name=Andrew Grimo<br />
<br />
[http://apvsbr700.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Alex Vlahopoulos<br />
#face=https://techontherun.sslpowered.com/techontherun.ca/alexthumb.png<br />
<br />
[http://asalga.wordpress.com/category/open-source/feed/]<br />
name=Andor Salga (asalga)<br />
<br />
[http://jabhad.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Mohamed Aden<br />
<br />
[http://jonathandeni.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Jonathan Deni<br />
#face=https://techontherun.sslpowered.com/techontherun.ca/jonthumb.png<br />
<br />
[http://manoutoftime.wordpress.com/category/open-source/feed/]<br />
name=Konstantin Novichikhin<br />
<br />
[http://scorchedicee.wordpress.com/category/Seneca/feed/]<br />
name=Adam Sone<br />
<br />
[http://murraysaul.wordpress.com/feed/]<br />
name=Murray Saul<br />
<br />
[http://xwn740arcadeproject.blogspot.com/feeds/posts/default]<br />
name=Arcade Project - LUX Group@<br />
#face=http://matrix.senecac.on.ca/~mpaivaneto/ourbaby.png<br />
<br />
[http://feeds.feedburner.com/lsblakk_open-source]<br />
name=Lukas Blakk (lsblakk)<br />
#face=http://avnerd.tv/sharedFiles/lukas_hackergotchi.png<br />
<br />
[http://nashutzu.blogspot.com/feeds/posts/default]<br />
name=George Popescu (GeorgeP)<br />
<br />
[http://blog.chris.tylers.info/index.php?/feeds/categories/20-Seneca-Planet.rss]<br />
name=Chris Tyler (ctyler)<br />
face=http://zenit.senecac.on.ca/~chris.tyler/chris_tyler_hackergotchi_4a.png<br />
<br />
[http://vocamus.net/dave/?feed=rss2&category_name=Seneca]<br />
name=David Humphrey<br />
<br />
[http://gratnam1.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Gajendran Ratnam (gratnam1)<br />
<br />
[http://senecajon.blogspot.com/feeds/posts/default]<br />
name=Jonathan Cheung (jcheung23)<br />
<br />
# Disabled 2011-04-28 - blog was removed<br />
#[http://blog.markparuzel.com/feed/]<br />
#name=Mark Paruzel<br />
<br />
[http://mmszuto.blogspot.com/feeds/posts/default]<br />
name=Michael Szutu<br />
<br />
[http://lsdaly.blogspot.com/feeds/posts/default]<br />
name=Louis Daly (lsdaly)<br />
<br />
# Disabled 2009-01-25 due to 404's (domain expired)<br />
#[http://www.foobartastic.com/feed/]<br />
#name=Tom Aratyn<br />
<br />
[http://bhearsum.blogspot.com/feeds/posts/default/-/seneca]<br />
name=Ben Hearsum<br />
<br />
# Following feed is invitation-only. Disabled 2010-09-23 CTyler<br />
#[http://www.jyzyy.blogspot.com/feeds/posts/default/-/opensource]<br />
#name=Jyoti<br />
<br />
# Re-enabled 2011-04-29 - new blog URL<br />
# Disabled 2009-09-15 due to 404's (site rearranged?)<br />
[http://tea.cesaroliveira.net/archives/tag/seneca/feed]<br />
name=Cesar Oliveira<br />
<br />
[http://r3ap3r.wordpress.com/category/seneca/feed]<br />
name=Brandon Collins<br />
<br />
# Disabled 2011-04-28 - blog was deleted<br />
#[http://jrgoncal.blogspot.com/feeds/posts/default]<br />
#name=Justin Goncalves (jrgoncal)<br />
#face=http://img517.imageshack.us/img517/9865/bearzp5.jpg<br />
<br />
# Disabled 2011-04-28 - blog is now private<br />
#[http://tlo5.blogspot.com/feeds/posts/default]<br />
#name=Tommy Lo (tlo5)<br />
<br />
[http://armenzg.blogspot.com/feeds/posts/default/-/open%20source]<br />
name=Armen Zambrano G. (armenzg)<br />
<br />
[http://mikemoz.blogspot.com/feeds/posts/default/-/Open%20Source]<br />
name=Michael Mullin<br />
<br />
[http://mikemoz.blogspot.com/feeds/posts/default/-/Mozilla_GFX]<br />
name=Michael Mullin<br />
<br />
# Returned 410 on 2008-09-13 - disabled CTyler<br />
#[http://rueenfiez.wordpress.com/category/open-source/feed/]<br />
#name=Rueen Fiez<br />
<br />
# Returning 404 on 2008-09-13 - disabled CTyler<br />
#[http://jsafavi.wordpress.com/category/open-source/feed/]<br />
#name=Jason Safavi<br />
<br />
[http://vlam6.wordpress.com/category/open-source/feed/]<br />
name=Vincent Lam<br />
<br />
[http://dejant.blogspot.com/feeds/posts/default]<br />
name=Dejan Tolj<br />
<br />
[http://shivaris.blogspot.com/feeds/posts/default/-/OSD600]<br />
name=Hien Huynh<br />
<br />
[http://raynrant.blogspot.com/feeds/posts/default]<br />
name=Andrew Raynier (JM)<br />
face=http://zenit.senecac.on.ca/wiki/imgs/Hackergotchi.png<br />
<br />
[http://vijeysdps909.blogspot.com/feeds/posts/default]<br />
name=Vijey Bala<br />
<br />
[http://sedejong.blogspot.com/feeds/posts/default]<br />
name=Shomar Dejonge<br />
<br />
[http://dbaranski.wordpress.com/category/open-source/feed/]<br />
name=Dominic Baranski<br />
<br />
#[http://crashopensource.wordpress.com/category/open-source/feed/]<br />
#name=Lukas Blakk<br />
<br />
[http://kmsingh.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Kerry M. Singh<br />
<br />
[http://tjduavis.wordpress.com/category/open-source/feed/]<br />
name=Timothy Duavis<br />
<br />
# Disabled 2011-04-28 - entire website is missing<br />
#[http://ashughes.com/?q=taxonomy/term/2/0/feed]<br />
#name=Anthony Hughes<br />
<br />
[http://opensourcekennethlee.blogspot.com/feeds/posts/default]<br />
name=Kenneth Lee<br />
<br />
[http://cleung.wordpress.com/category/Seneca/feed/]<br />
name=Catherine Leung<br />
<br />
[http://dtheosab.wordpress.com/category/open-source/feed/]<br />
name=Daino Theosabrata<br />
<br />
# This is my old blog<br />
[http://simon-jung.blogspot.com/feeds/posts/default]<br />
name=Simon Jung (old)<br />
<br />
[http://aeraj.blogspot.com/feeds/posts/default/-/open%20source]<br />
name=AJ Rehman<br />
<br />
[http://xrayon.blogspot.com/feeds/posts/default]<br />
name=Fima Kachinski<br />
<br />
[http://littlesvr.ca/grumble/category/safeforseneca/feed/]<br />
name=Andrew Smith<br />
<br />
[http://littlesvr.ca/masters/feed]<br />
name=Andrew Smith (master's)<br />
<br />
[http://jbopensrc.wordpress.com/category/open-source/feed]<br />
name=Jesse Buchanan<br />
<br />
[http://ayhfung.blogspot.com/feeds/posts/default]<br />
name=Andrew Fung<br />
<br />
# Returned 404 on 2008-09-13 - disabled CTyler<br />
#[http://sloose.wordpress.com/category/open-source/feed/]<br />
#name=Peter Ljubanovic<br />
<br />
[http://mozcoz.blogspot.com/feeds/posts/default/-/Open%20Source]<br />
name=Amit Gundu<br />
<br />
# Changed CTyler 2009-02-12 from [http://www.blogger.com/feeds/15922666655846514311/blogs]<br />
[http://dsmukherji.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Devashish<br />
<br />
[http://yhan11.wordpress.com/category/open-source/feed]<br />
name=Yongsheng Han<br />
<br />
[http://peter.sykokillers.com/category/open-source/feed/]<br />
name=Peter Chan<br />
<br />
[http://www.c3dl.org/index.php/category/c3dl-dev/feed]<br />
name=Seneca Canvas3D Team<br />
<br />
# Updated 2011-04-28 - corrected feed URL<br />
[http://peterevanoff.wordpress.com/category/open-source/feed/]<br />
name=Peter Evanoff<br />
<br />
# Disabled 2011-04-28 - flagged as a malware-loaded site by Google<br />
<br />
#[http://radoye.net1zen.com/wp-rss2.php?cat=3]<br />
#name=Radovan Nesic<br />
<br />
[http://blog.cresencia.ca/category/open-source/osd600/feed/]<br />
name=Joseph Cresencia<br />
<br />
[http://bertenshaw.blogspot.com/feeds/posts/default]<br />
name=David Bertenshaw<br />
<br />
[http://ljubomirgorscak.blogspot.com/feeds/posts/default]<br />
name=Ljubomir Gorscak<br />
<br />
[http://sameropensource.blogspot.com/feeds/posts/default]<br />
name=Samer Ziadeh (samer)<br />
<br />
# Following feed not working and temporarily disabled<br />
# 2010-09-23 by CTyler<br />
#[http://jamesboston.ca/cms/taxonomy/term/1/0/feed]<br />
#name=James Boston<br />
#face=http://jamesboston.ca/hackergotchi.png<br />
<br />
[http://dailypackage.fedorabook.com/index.php?/feeds/index.rss2]<br />
name=Fedora Daily Package<br />
<br />
[http://blog.fardad.com/feeds/posts/default/-/Seneca]<br />
name=Fardad Soleimanloo<br />
<br />
[http://selmys.wordpress.com/category/opensource/feed]<br />
name=John Selmys<br />
face=http://cs.senecac.on.ca/~selmys/john_selmys_hackergotchi.png<br />
<br />
[http://pconstantino.wordpress.com/feed]<br />
name=Patricia Constantino<br />
<br />
[http://bombshelter13.blogspot.com/feeds/posts/default]<br />
name=Katherine Masseau<br />
<br />
[http://zadkielm.blogspot.com/feeds/posts/default/-/open%20source]<br />
name=Ezadkiel Marbella<br />
<br />
[http://blog.sidkalra.com/category/opensource/feed]<br />
name=Sid Kalra<br />
<br />
[http://pplam3.blogspot.com/feeds/posts/default]<br />
name=Patrick Lam<br />
<br />
# Disabled 2011-04-28 - blog is now private<br />
#[http://twlai1.blogspot.com/feeds/posts/default]<br />
#name=Tony Lai<br />
<br />
[http://dee132.blogspot.com/feeds/posts/default/-/seneca]<br />
name=Chris Bishop<br />
<br />
# Updated 2011-04-28 - updated feed URL<br />
[http://zghansar.wordpress.com/category/open-source/feed/]<br />
name=Zaid Ghansar<br />
face=http://www.alhudainstitute.ca/zaid/z.png<br />
<br />
[http://aaronmt.github.com/atom.xml]<br />
name=Aaron Train<br />
face=http://matrix.senecac.on.ca/~amtrain/other/mypic.png<br />
<br />
[http://scottosd.blogspot.com/feeds/posts/default/-/Open%20Source/]<br />
name=Scott Lunel<br />
<br />
# Updated 2009-04-16, new blog. - scarter4<br />
# Disabled 2009-11-27 due to wrong feed URL<br />
#[http://scarter4.wordpress.com/category/seneca/]<br />
#name=Stephen Carter<br />
<br />
# Disabled 2009-01-23 CTyler due to 404s<br />
#[http://shdinis.blogspot.com/feeds/posts/default]<br />
#name=Shawn Dinis<br />
<br />
[http://belligero.org/index.php?option=com_content&view=section&id=1&format=feed&type=rss]<br />
name=Jason Tarka<br />
<br />
# Updated 2011-04-28 - no more tag, but still Seneca related<br />
[http://petermcintyre.wordpress.com/feed/]<br />
name=Peter McIntyre<br />
<br />
[http://vesperrin.blogspot.com/feeds/posts/default/-/open%20source]<br />
name=Leonard Lee (vesper)<br />
<br />
[http://jsdoodnauth.wordpress.com/category/open-source/feed/]<br />
name=Joshua Doodnauth<br />
<br />
[http://johnhford.blogspot.com/feeds/posts/default/-/Open%20Source]<br />
name=John Ford (John64)<br />
<br />
[http://mohaksblog.blogspot.com/feeds/posts/default]<br />
name=Mohak Vyas<br />
#face=http://matrix.senecac.on.ca/~mdvyas/MohakVyas.png<br />
<br />
[http://pdirezze.blogspot.com/feeds/posts/default]<br />
name=Paul DiRezze<br />
<br />
# Following link no longer valid. Disabled 2010-09-23 CTyler<br />
#[http://www.ndaversa.com/category/open-source/feed]<br />
#name=Nino D'Aversa<br />
<br />
[http://miltonpaiva.wordpress.com/feed/]<br />
name=Milton Paiva<br />
#face=http://matrix.senecac.on.ca/~mpaivaneto/orkut.png<br />
<br />
[http://de-luxer.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Nestor Chan<br />
#face=http://matrix.senecac.on.ca/~tnchan/n516840997_9173.PNG<br />
<br />
[http://varinderjhand.wordpress.com/feed/]<br />
name=Varinder Singh <br />
<br />
[http://ajhooper.blogspot.com/feeds/posts/default]<br />
name=Aaron Hooper<br />
<br />
[http://nadavid.blogspot.com/feeds/posts/default]<br />
name=Neil David<br />
<br />
[http://cdpatel1.blogspot.com/feeds/posts/default]<br />
name=Chinmay Patel<br />
#face=http://www.geocities.com/chinmay_patel@ymail.com/chinmay.jpg<br />
<br />
[http://jvalianes.blogspot.com/feeds/posts/default]<br />
name=Jesse Valianes<br />
<br />
[http://bbarcick.blogspot.com/feeds/posts/default/-/Open%20Source]<br />
name=Bartosz Barcicki<br />
<br />
[http://heidenreich.wordpress.com/tag/seneca-college/feed/]<br />
name=Michal Heidenreich<br />
<br />
[http://kezhong.wordpress.com/feed/atom/]<br />
name=Kezhong Liang <br />
<br />
[http://wfred.wordpress.com/category/open-source/feed/]<br />
name=Fred Wang<br />
<br />
[http://jsinghfoss.wordpress.com/category/spring-framework/feed/]<br />
name=Jatinder Singh<br />
<br />
[http://rparsi.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Rahi Parsi<br />
<br />
# Changed 2011-04-28 - missing a capital "S" from Seneca to display feed<br />
[http://aaronrey15.blogspot.com/feeds/posts/default/-/Seneca]<br />
name=Aaron Chan<br />
<br />
# Disabled 2011-04-28 - posts were deleted, empty feed<br />
#[http://flashalive.wordpress.com/category/Open%20Source/feed/]<br />
#name=Ryan Wang<br />
<br />
[http://kvuhome.blogspot.com/feeds/posts/default/-/Open%20Source]<br />
name=Khanh Vu<br />
<br />
[http://daeseonmoon.wordpress.com/category/open-source/feed/]<br />
name=Daeseon Moon<br />
<br />
[http://abraini.wordpress.com/category/seneca/feed/]<br />
name=Andrew Braini<br />
<br />
[http://minicheong.blogspot.com/feeds/posts/default]<br />
name=Frankie Law<br />
<br />
# Following feed changed from http://www.heyqule.net/blog/tech/oss/feed<br />
# on 2010-09-23 by CTyler.<br />
[http://www.heyqule.net/taxonomy/term/44/0/feed]<br />
name=Allen JF Xie (heyqule)<br />
<br />
[http://farhadnorouzi.blogspot.com/feeds/posts/default]<br />
name=Farhad Norouzi<br />
<br />
[http://jdeport.wordpress.com/category/software-development/open-source/feed/]<br />
name=John Dang<br />
<br />
[http://pliu.wordpress.com/category/open-source/feed/]<br />
name=Peter Liu<br />
<br />
# Feed not working - temporarily disabled 2010-09-23 CTyler<br />
#[http://www.jerrypau.ca/?feed=rss2&cat=3]<br />
#name=Jerry Pau<br />
#face=http://www.jerrypau.ca/blog-face-1.png<br />
<br />
[http://blog.wikiscraps.com/feeds/posts/default/-/oss]<br />
name=M. Mead Armsby (mead)<br />
<br />
[http://paritosha.blogspot.com/feeds/posts/default]<br />
name=Paritosh Aggarwal(paritosh1010)<br />
<br />
# Private blog. Disabled 2010-09-23 CTyler.<br />
#[http://myblog110.wordpress.com/category/open-source/feed]<br />
#name=Tahereh<br />
<br />
# Disabled 2011-04-28 - empty feed, all posts were removed<br />
#[http://challenger110.wordpress.com/category/software-development/open-source/censored/feed/]<br />
#name=Davoud Salahi Rad<br />
<br />
[http://wb-os.blogspot.com/feeds/posts/default]<br />
name=Le Yang<br />
<br />
[http://garykwong.wordpress.com/category/education/feed/]<br />
name=Gary Kwong (nth10sd)<br />
<br />
[http://yuenhoe.co.cc/blog/category/mozilla/feed/]<br />
name=Lim Yuen Hoe (moofang)<br />
<br />
# Disabled 2011-04-27 - empty feed, needs to be udpated<br />
#[http://tonychestnut.wordpress.com/category/mozilla/ubiquity/feed/]<br />
#name=Vu Dinh The (tonyvu)<br />
<br />
[http://opensourceproject.wordpress.com/category/open-source/feed/]<br />
name=Nabeel Khan (nkhan26)<br />
<br />
# Disabled 2011-04-27 - suspended domain<br />
#[http://solfu.net/tech/category/personas-for-thunderbird/feed/]<br />
#name=Yaoquan (seith)<br />
<br />
[http://xiajunshi.wordpress.com/category/open-source/feed/]<br />
name=Shelley Shi<br />
<br />
[http://hendrikinmozilla.wordpress.com/feed/]<br />
name=Hendrik<br />
<br />
[http://t3rrychan.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Terry Chen (jchen124)<br />
<br />
[http://blog.bchao.ca/feeds/posts/default?alt=rss]<br />
name=Boris Chao<br />
<br />
[http://ahiltssbr700.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Adam Hilts<br />
<br />
[http://ysasaki600.wordpress.com/feed/]<br />
name=Yu Sasaki<br />
<br />
[http://enderstruth.wordpress.com/category/open-source/feed/]<br />
name=Roger Dicke<br />
<br />
[http://wobblyretroaction.blogspot.com/feeds/posts/default/-/Open%20source]<br />
name=Matthew Lam<br />
<br />
[http://asydik.wordpress.com/category/professional/open-source/feed/]<br />
name=Mickael Medel (aSydiK)<br />
<br />
[http://cwdesautels.blogspot.com/feeds/posts/default]<br />
name=Carl Desautels<br />
<br />
[http://rselby-oop344.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Remington Selby<br />
<br />
[http://mikey-osd600a.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Michael Dennis<br />
<br />
# Disabled 2011-04-27 - empty blog<br />
#[http://tjprogramming.blogspot.com/feeds/posts/default/-/seneca]<br />
#name=Timothy Catibog<br />
<br />
[http://horndavid.blogspot.com/feeds/posts/default?alt=rss]<br />
name=David Horn<br />
<br />
[http://annasob.wordpress.com/feed/]<br />
name=Anna Sobiepanek<br />
<br />
[http://drozhkov.blogspot.com/feeds/posts/default/-/seneca]<br />
name=Dmitriy Rozhkov<br />
<br />
[http://www.hodgin.ca/?feed=rss2&cat=4]<br />
name=Daniel Hodgin<br />
<br />
[http://xderick.blogspot.com/feeds/posts/default/-/OSD]<br />
name=Yong Hong<br />
<br />
# This next link does not lead to an RSS or Atom feed. Disabled 2009-10-25 by CTyler.<br />
#[http://hoonkoon.blogspot.com/2009/09/oop344.html]<br />
#name=Taehoon Kim<br />
<br />
[http://s2000c.blogspot.com/feeds/posts/default/-/OOP344]<br />
name=Sunny Chau<br />
<br />
# This next link does not lead to an RSS or Atom feed. Disabled 2009-10-25 by CTyler.<br />
#[http://s2000c.blogspot.com/2009/09/oop344c.html]<br />
#name=Sunny Chau<br />
<br />
[http://kxu9.blogspot.com/feeds/posts/default]<br />
name=Kai Xu<br />
<br />
[http://oop-era.blogspot.com/feeds/posts/default]<br />
name=Eric Austerberry<br />
<br />
[http://docsage.blogspot.com/feeds/posts/default/-/OOP344]<br />
name=Eric Dell<br />
<br />
[http://ehren.wordpress.com/category/Seneca/feed/]<br />
name=Ehren Metcalfe<br />
<br />
[http://bsmith19.wordpress.com/category/Seneca/feed/]<br />
name=Brandon Smith<br />
<br />
[http://dcucereavii.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Diana Cucereavii<br />
<br />
# Disabled 2011-04-27 - site unreachable<br />
#[http://www.savantosis.com/?feed=rss2&cat=3]<br />
#name=Justin Robertson<br />
<br />
[http://paul-oop344.blogspot.com/feeds/posts/default/]<br />
name=Paul Repasi<br />
<br />
[http://istessema.wordpress.com/category/oop344/feed/]<br />
name=Iyosias Tessema<br />
<br />
[http://nedape.blogspot.com/feeds/posts/default]<br />
name=Neda Pezeshki<br />
<br />
[http://justletmepassoop344.blogspot.com/feeds/posts/default]<br />
name=Brian Parreno<br />
<br />
[http://dliu53.wordpress.com/category/open-source/feed/]<br />
name=Donghui Liu<br />
<br />
# Disabled 2011-04-27 - site not found<br />
#[http://oopblog.tdotshack.net/feeds/posts/default/-/OOP344]<br />
#name=Ryan Alexander<br />
<br />
[http://oop344ylseow.blogspot.com/feeds/posts/default]<br />
name=Yip Lim, Seow<br />
<br />
[http://mercedes-oop344.blogspot.com/feeds/posts/default]<br />
name=Suwon An<br />
<br />
[http://dtychshenko.blogspot.com/feeds/posts/default/-/OOP344]<br />
name=Dmitriy Tychshenko<br />
<br />
[http://victran.blogspot.com/feeds/posts/default/-/OOP344]<br />
name=Victor Tran<br />
<br />
# Changed 2011-04-27 - updated feed URL to proper<br />
[http://krazyazn.blogspot.com/feeds/posts/default]<br />
name=Michael Lin<br />
<br />
[http://xshi18.blogspot.com/feeds/posts/default]<br />
name=Xiaozhe Shi<br />
<br />
[http://feihong-xiong.blogspot.com/feeds/posts/default]<br />
name=Feihong Xiong<br />
<br />
# Changed 2011-11-01 - created category just for PlanetCDOT<br />
[http://orbitalstation.wordpress.com/category/planetcdot/feed/]<br />
name=Hasan (northWind) Kamal-Al-Deen<br />
face=http://matrix.senecac.on.ca/~hkamal-al-deen/images/Exclaim65x85.png<br />
<br />
[http://hduan2.wordpress.com/feed/]<br />
name= Haoliang Duan<br />
<br />
[http://anastasias-myblog.blogspot.com/feeds/posts/default/-/OOP344]<br />
name= Anastasia Semionova<br />
<br />
[http://franksun123.blogspot.com/feeds/posts/default/]<br />
name= Dong Sun<br />
<br />
[http://rkyoop344.blogspot.com/feeds/posts/default/]<br />
name=Keyan Ren<br />
<br />
[http://ctran13.blogspot.com/feeds/posts/default/-/oop344]<br />
name=Chi-Lea Tran<br />
<br />
[http://szymonsoop.blogspot.com/feeds/posts/default/]<br />
name= Szymon Ahmed<br />
<br />
[http://ywang268.blogspot.com/feeds/posts/default/]<br />
name=Yu Wang<br />
<br />
[http://wangcong422.blogspot.com/feeds/posts/default/]<br />
name=Cong Wang<br />
<br />
[http://dennyp.wordpress.com/category/Seneca/feed/]<br />
name=Denny Papagiannidis<br />
<br />
# Blog not found. Disabled 2010-09-23 CTyler.<br />
#[http://java-chinmay.blogspot.com/feeds/posts/default]<br />
#name= Chinmay Patel<br />
<br />
[http://saecob.blogspot.com/feeds/posts/default/-/OpenSource]<br />
name= Sergiu Ecob<br />
<br />
# Disabled 2011-04-27 - blog deleted<br />
#[http://satijas.wordpress.com/category/OOP344/feed/]<br />
#name=Sasha Atijas<br />
<br />
# 404. Disabled 2010-09-23 CTyler.<br />
#[http://auzix.com/seneca/?feed=rss2]<br />
#name=Tyler Hackwood<br />
<br />
#[http://starbuck-blog.blogspot.com/feeds/posts/default]<br />
#name=Verity Li<br />
<br />
[http://gkrilov.blogspot.com/feeds/posts/default]<br />
name=Greg Krilov<br />
<br />
[http://qinzhi2001.blogspot.com/feeds/posts/default]<br />
name=David Chen<br />
<br />
[http://tchen-oop344.blogspot.com/feeds/posts/default]<br />
name=Terence Chen<br />
<br />
[http://opp344-yxue.blogspot.com/feeds/posts/default]<br />
name=Yong Xue<br />
# Disabled 2011-04-28 - had 2 other duplicate feeds<br />
# http://opp344-yxue.blogspot.com/feeds/posts/default/-/seneca<br />
# http://opp344-yxue.blogspot.com/feeds/posts/default/-/OOP344<br />
<br />
[http://ttsuji1.blogspot.com/feeds/posts/default]<br />
name=Trevor Tsuji<br />
<br />
[http://oyoung4.blogspot.com/feeds/posts/default]<br />
name=Oliver Young<br />
<br />
[http://minyxo.blogspot.com/feeds/posts/default/-/Open%20Source]<br />
name=Edward Sin<br />
<br />
# Blog not found - disabled 2010-09-23 CTyler<br />
#[http://oop344f09-niki.blogspot.com/feeds/posts/default]<br />
#name=Niki Simmalavong<br />
<br />
[http://jdbcdps.blogspot.com/feeds/posts/default]<br />
name=Julia Vasserman<br />
<br />
[http://shunyao-cpa.blogspot.com/feeds/posts/default]<br />
name=Shun Yao Zhang<br />
<br />
# Disabled 2009-11-27 due to 500's on feed link<br />
# Re-enabled 2011-04-27 - incorrect URL format fixed<br />
[http://oop344ylseow.blogspot.com/feeds/posts/default]<br />
name=Yip Lim Seow<br />
<br />
[http://capereir.wordpress.com/feed/]<br />
name=Chris Pereira<br />
<br />
[http://dev-blog.zerogin.com/category/opensource/feed/]<br />
name=Tom Wisniewski (t0mmyw)<br />
<br />
# Disabled 2011-04-27 - empty feed, rest of blog is not related<br />
#[http://majorbludd.wordpress.com/category/school/feed/]<br />
#name=Michael Dawson<br />
<br />
[http://cdnpadawan.wordpress.com/feed/]<br />
name=Matthew Daniels<br />
<br />
[http://processingjs.org/blog/?feed=rss2]<br />
name=Processing.js Blog<br />
<br />
[http://dseifried.wordpress.com/category/school/feed/]<br />
name=David Seifried<br />
<br />
[http://tandemwebdesign.ca/blog/?feed=rss2&cat=3]<br />
name=Matthew Adams<br />
<br />
[http://s-aleinikov.blog.ca/feed/atom/posts/]<br />
name=Sergey Aleinikov<br />
<br />
[http://wfchen2010.blogspot.com/feeds/posts/default]<br />
name=Wen Fang Chen<br />
<br />
[http://donna-oberes.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Donna Oberes<br />
<br />
[http://carolynwoodley.blogspot.com/feeds/posts/default]<br />
name=Carolyn Woodley<br />
<br />
[http://shengwei-seneca.blogspot.com/feeds/posts/default]<br />
name=Shengwei Wang<br />
<br />
[http://zakoop344.blogspot.com/feeds/posts/default]<br />
name=Wei Tong<br />
<br />
[http://gtawaf.blogspot.com/feeds/posts/default/-/Seneca]<br />
name=Gamal Tawaf <br />
<br />
[http://rift-tlosam.blogspot.com/feeds/posts/default/-/seneca]<br />
name=Brendan McDorman<br />
<br />
[http://hdc23.wordpress.com/category/OOP344/feed]<br />
name=Dachuan Huang<br />
<br />
# Disabled 2011-04-27 - blank feed, aged blod<br />
#[http://qwu26.blogspot.com/feeds/posts/default/-/OOP344]<br />
#name=Qingxi Wu<br />
<br />
# Disabled 2011-04-27 - blank blog<br />
#[http://lwang162.blogspot.com/feeds/posts/default/-/OOP344]<br />
#name=LianHe Wang<br />
<br />
# Disabled 2011-04-27 - blank blog, aged<br />
#[http://bmcohen.blogspot.com/feeds/posts/default/-/seneca]<br />
#name=Bryan Cohen<br />
<br />
[http://feliploko.wordpress.com/category/seneca/feed]<br />
name=Felipe de Oliveira<br />
<br />
# Following feed reports invalid content type.<br />
# Disabled 2010-09-23 CTyler<br />
#[http://lwang168.blogspot.com/feeds/posts/-/oop344]<br />
#name=Liang Wang<br />
<br />
[http://shunyao-cpa.blogspot.com/feeds/posts/default]<br />
name=shun yao zhang<br />
<br />
[http://galewis.blogspot.com/feeds/posts/default]<br />
name=Gustone Lewis<br />
<br />
[http://hmo6.blogspot.com/feeds/posts/default]<br />
name=Mo Hsiu Mei<br />
<br />
[http://derekambrose.blogspot.com/feeds/posts/default/-/open%20source]<br />
name=Derek Ambrose<br />
<br />
[http://scottdowne.wordpress.com/category/open-source/feed/]<br />
name=Scott Downe<br />
<br />
# Disabled 2011-04-27 - blog deleted<br />
#[http://anthonyisgood.blogspot.com/feeds/posts/default/-/open%20source]<br />
#name = Anthony Alves<br />
<br />
[http://jjleeos.blogspot.com/feeds/posts/default]<br />
name = Jeffrey Lee<br />
<br />
[http://harjinderv.tumblr.com/tagged/Open_Source/rss]<br />
name = Harjinder Virdi<br />
<br />
[http://cldenobrega.wordpress.com/category/open-source/feed/]<br />
name = Crystal de Nobrega (cldenobrega)<br />
<br />
[http://lchen97.blogspot.com/feeds/posts/default]<br />
name=Chris Chen<br />
<br />
# Parked domain. Disabled 2010-09-23 CTyler<br />
#[http://hotweiss.lifeflayer.com/?feed=atom]<br />
#name=Tianqi Liu<br />
<br />
[http://oleg-oop.blogspot.com/feeds/posts/default]<br />
name=Aleh Pliats<br />
<br />
[http://88mishok.blogspot.com/feeds/posts/default]<br />
name=Francois Des Jarlais<br />
<br />
[http://bikarin.blogspot.com/feeds/posts/default]<br />
name=Irina Balzamova<br />
<br />
[http://mashhaque.blogspot.com/feeds/posts/default]<br />
name=Mashfique Haque<br />
<br />
[http://yxue11.blogspot.com/feeds/posts/default]<br />
name=Yong Xue<br />
<br />
[http://tdao75.blogspot.com/feeds/posts/default]<br />
name=Thanh Dao<br />
<br />
[http://minooz.wordpress.com/category/CDOT/feed/]<br />
name=Minoo Ziaei<br />
<br />
[http://gbatumbya.wordpress.com/category/seneca/cdot/feed/]<br />
name=Grace Simon Batumbya<br />
<br />
[http://sonnilion.wordpress.com/feed/]<br />
name=Matt Postill<br />
<br />
[http://acchung1.blogspot.com/feeds/posts/default/-/oop344]<br />
name=Alex Chun Yang Chung<br />
<br />
[http://hckim.wordpress.com/category/open-source/feed/]<br />
name=Han Chul Kim<br />
<br />
[http://xizhangblog.blogspot.com/feeds/posts/default/-/oop344]<br />
name=Xi Zhang<br />
<br />
# Modified 2011-04-27 - changed from blank category<br />
[http://lwu11.blogspot.com/feeds/posts/default]<br />
name=Ling Wu<br />
<br />
[http://jasonquan.wordpress.com/category/OOP344/feed/]<br />
name=Jason Quan<br />
<br />
[http://myoop344blog.blogspot.com/feeds/posts/default/]<br />
name=Xiongwen LU<br />
<br />
[http://0zzym.wordpress.com/feed]<br />
name=Osman Mirza<br />
<br />
[http://adgezaza.posterous.com/rss.xml?tag=open%20source]<br />
name=Adrian Maurer<br />
<br />
[http://kumailhabib.blogspot.com/feeds/posts/default]<br />
name=Kumail Habib<br />
<br />
[http://imadorki3.blogspot.com/feeds/posts/default]<br />
name=Robin Co<br />
<br />
[http://danapao026.blogspot.com/feeds/posts/default]<br />
name=Don Armin Napao<br />
<br />
[http://cgm087.blogspot.com/feeds/posts/default/-/CDOT]<br />
name=Christopher G. Missen<br />
<br />
[http://crgosselin.blogspot.com/feeds/posts/default]<br />
name=Chris Ryan Gosselin<br />
<br />
[http://slaw12.wordpress.com/feed/ ]<br />
name=Stephanie Law<br />
<br />
[http://ysliu2.blogspot.com/feeds/posts/default]<br />
name=Yansong Liu<br />
<br />
[http://www.drizhepolov.com/blog/?feed=rss2]<br />
name=Vladimir Drizhepolov<br />
<br />
[http://bhavanesh.wordpress.com/feed/]<br />
name=Bhavanesh Patel<br />
<br />
[http://xwu0102.blogspot.com/feeds/posts/default/-/oop344]<br />
name=Xiaojiang Wu<br />
<br />
[http://rhui4.wordpress.com/feed/ ]<br />
name=Richard Hui<br />
<br />
[http://invinciblyignorant.wordpress.com/category/OOP344/feed/]<br />
name=Jason Burton<br />
<br />
[http://goldenration.wordpress.com/feed/]<br />
name=HongGeun Park<br />
<br />
[http://thupten.veryusefulinfo.com/?feed=rss2]<br />
name=Thupten Choephel<br />
<br />
[http://priyadeep.wordpress.com/feed/]<br />
name=Priyadeep Gill<br />
<br />
[http://kyle205website.info/wordpress/?feed=rss2]<br />
name=Khai Huynh<br />
<br />
[http://dale.io/open-source.xml]<br />
name=Dale Karp<br />
<br />
[http://vbluzmans.wordpress.com/feed/]<br />
name=Vitaly Bluzmans<br />
<br />
[http://akkimblog.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Kerry Taylor<br />
<br />
<br />
[http://alf1488.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Yegor Tyunin<br />
<br />
[http://sbr600.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Matthew Ortofsky<br />
<br />
[http://pbrown9.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Paul Brown<br />
<br />
[http://jzaidi.wordpress.com/feed/]<br />
name=Jawwad Zaidi<br />
<br />
[http://blog.rainulf.ca/category/CDOT/feed/]<br />
name=Rainulf Pineda<br />
<br />
[http://donchel.wordpress.com/feed/]<br />
name=Dong Cheol Cha<br />
<br />
[http://sweerdenburg.wordpress.com/category/seneca/feed/]<br />
name=Steven Weerdenburg<br />
<br />
[http://jyang42.blogspot.com/feeds/posts/default]<br />
name=Jing Yang<br />
<br />
[http://tarinc.wordpress.com/feed/]<br />
name=Tarin Choudhury<br />
<br />
[http://jtdonaldson21.blogspot.com/feeds/posts/default]<br />
name=Jeshu Donaldson<br />
<br />
[http://bccp32.blogspot.com/feeds/posts/default]<br />
name=Yauheni Khabian<br />
<br />
[http://mark-os.blogspot.com/feeds/posts/default]<br />
name=Mark Eamiguel<br />
<br />
[http://kweber1.blogspot.com/feeds/posts/default]<br />
name=Kyle Weber<br />
<br />
[http://mustafaredha.wordpress.com/category/planet-cdot/feed]<br />
name=Mustafa Redha<br />
<br />
[http://andrewasdesigned.blogspot.com/feeds/posts/default/-/SBR600]<br />
name=Andrew Singh<br />
<br />
[http://escom0.blogspot.com/feeds/posts/default]<br />
name=Eric Shum<br />
<br />
# Disabled 2011-04-27 - blog was deleted<br />
#[http://open-ht.blogspot.com/feeds/posts/default]<br />
#name=Hoc Tran<br />
<br />
[http://vanjason.wordpress.com/category/sbr600/feed]<br />
name=Jason Van<br />
<br />
[http://kpangilinan.wordpress.com/feed]<br />
name=Kenneth Pangilinan<br />
<br />
[http://ajcondinho.blogspot.com/feeds/posts/default/-/opensource]<br />
name=Andrew Condinho<br />
<br />
[http://cahayamu.com/feed/]<br />
name=Cahayamu<br />
<br />
[http://blog.esmnetworks.com/category/planet-cdot/feed]<br />
name=Adrian Pruteanu<br />
<br />
[http://stevebologna.wordpress.com/category/Open-Source/feed/]<br />
name=Stephen Bologna<br />
<br />
[http://www.winterleaf.ca/blog/category/oop344/feed/]<br />
name=Daniel Slessarev<br />
<br />
[http://ycshon.blogspot.com/feeds/posts/default]<br />
name=Young Chol Shon<br />
<br />
[http://jwpark2.blogspot.com/feeds/posts/default]<br />
name=Jaewoo Park<br />
<br />
[http://klasconia.wordpress.com/feed/]<br />
name=Kevin Lasconia<br />
<br />
[http://kaitlynmcdonald.wordpress.com/feed/]<br />
name=Kaitlyn McDonald<br />
<br />
[http://jrobinson7.wordpress.com/feed/]<br />
name=James Robinson<br />
<br />
[http://trusu.blogspot.com/feeds/posts/default]<br />
name=Traian Rusu<br />
<br />
[http://blockrockinpete.blogspot.com/feeds/posts/default/-/OSD600]<br />
name=Pete Leaning<br />
<br />
[http://tyler-taehee-lee.blogspot.com/feeds/posts/default/-/SBR600]<br />
name=Tae Hee Lee<br />
<br />
<br />
[http://www.kaitlyncallow.com/Blog/?feed=rss2&cat=87]<br />
name=Kaitlyn Callow<br />
face=http://www.kaitlyncallow.com/Dump/kait_avatar.jpg<br />
<br />
[http://www.kaitlyncallow.com/Blog/?feed=rss2&cat=96]<br />
name=Kaitlyn Callow<br />
face=http://www.kaitlyncallow.com/Dump/kait_avatar.jpg<br />
<br />
[http://saad-husain.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Saad Husain<br />
<br />
[http://jevangelos.wordpress.com/feed/]<br />
name=James Evangelista<br />
<br />
# Disabled 2011-04-27 - not a feed link<br />
#[http://sajed481.wordpress.com/SBR600/]<br />
#name=M.A Sajed Shadani<br />
<br />
[http://rizwanhaq.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Rizwan Haq<br />
<br />
[http://tuori.tk/blog/blogs/blog1.php?tempskin=_rss2&cat=15]<br />
name=Matthew Tuori<br />
<br />
[http://ktaraghi.blogspot.com/feeds/posts/default]<br />
name=Khosro Taraghi<br />
<br />
[http://opensourceftw.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Anthony Boccia<br />
<br />
[http://perfectlylogical.wordpress.com/category/sbr600/feed/]<br />
name=Stephen Hall<br />
<br />
[http://rocellaj.wordpress.com/feed/]<br />
name=Rocella Jimenez<br />
<br />
[http://justinpaulmorgan.blogspot.com/feeds/posts/default]<br />
name=Justin Morgan<br />
<br />
[http://gcasella.blogspot.com/feeds/posts/default]<br />
name=Gian-Luca Casella<br />
<br />
[http://archanasahota.com/category/open-source/feed/]<br />
name=Archana Sahota<br />
<br />
[http://pratikamin.wordpress.com/category/sbr600/feed/]<br />
name=Pratik Amin<br />
<br />
[http://syang00.wordpress.com/feed/]<br />
name=Stephanie Yang<br />
<br />
[http://tewestacott.wordpress.com/category/SBR600/feed/]<br />
name=Todd Westacott<br />
<br />
[http://aparda.wordpress.com/category/SBR600//feed/]<br />
name=Andrew Parda<br />
<br />
[http://gjuhasz1.wordpress.com/feed/]<br />
name=Gergely Juhasz<br />
<br />
[http://completefail.wordpress.com/category/SBR600/feed/]<br />
name=Joshua Y. Koh<br />
<br />
[http://myuberwebsite.blogspot.com/feeds/posts/default]<br />
name=Dmitry Artemenko<br />
<br />
[http://cgomes7.wordpress.com/feed/]<br />
name=Cesar Gomes<br />
<br />
[http://supbroseph.wordpress.com/feed/]<br />
name=Houssam haidar<br />
<br />
[http://www.bradchen.com/rss/blog/open%20source]<br />
name=Brad Chen (vvasabi)<br />
<br />
[http://asabir.wordpress.com/feed/]<br />
name=Adeel Sabir (asabir)<br />
<br />
[http://libresparks.wordpress.com/category/SBR600/feed/]<br />
name=Alfred Liu<br />
<br />
[http://acook6.blogspot.com/feeds/posts/default/-/open-source]<br />
name=Alan Cook<br />
<br />
[http://coding.shaunofthelive.com/feeds/posts/default/-/oop344]<br />
name=Shaun Hill<br />
<br />
[http://maoli1207.blogspot.com/feeds/posts/default/-/open-source]<br />
name=Mao Hua Li<br />
<br />
# tmp disabled<br />
#[http://fossjon.wordpress.com/feed/]<br />
#name=Jon Chiappetta<br />
<br />
[http://dperit.blogspot.com/feeds/posts/default/-/cdot]<br />
name=David Perit<br />
<br />
[http://szafar8.wordpress.com/tag/cdot/feed/]<br />
name=Salman Zafar<br />
<br />
[http://mbuttu.wordpress.com/category/Open-Source/feed/]<br />
name=Mohammed Buttu<br />
<br />
[http://brianlimtemp.blogspot.com/feeds/posts/default/-/CDOT]<br />
name=Brian Lim<br />
<br />
[http://drigato.wordpress.com/category/open-source/feed/]<br />
name=Denise Rigato<br />
<br />
[http://jbraffoul.wordpress.com/category/open-source/feed/]<br />
name=Jordan Raffoul<br />
<br />
[http://kuznetsovnikita.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Nikita Kuznetsov<br />
<br />
[http://noahgitalis.wordpress.com/category/open-source/feed/]<br />
name=Noah Gitalis<br />
<br />
[http://rhotin.wordpress.com/category/open-source/feed/]<br />
name=Roman Hotin<br />
<br />
[http://nm486.wordpress.com/category/open-source/feed]<br />
name=Stanley Tsang<br />
<br />
[https://brattahlid.wordpress.com/tag/foss/feed/]<br />
name=Abhishek Bhatnagar<br />
<br />
[http://mendozamiche.wordpress.com/category/open-source/feed]<br />
name=Michelle Mendoza<br />
<br />
[http://kenxu99.wordpress.com/category/open-source/feed]<br />
name=Qian (Ken) Xu<br />
<br />
[http://steventseng.wordpress.com/category/open-source/feed/]<br />
name=Ching Wei Tseng (Steven)<br />
<br />
[http://myprogrammingblog.com/category/open-source/feed/]<br />
name=Anatoly Spektor<br />
<br />
[http://jasonmarciniak.wordpress.com/feed/]<br />
name=Jason Marciniak<br />
<br />
[http://hungryr.wordpress.com/category/open-source/feed]<br />
name=Hyungryul Steven Chun<br />
<br />
[http://jbhuestis.wordpress.com/feed/]<br />
name=Jordan Huestis<br />
<br />
[http://nicklmbrt.wordpress.com/feed]<br />
name=Nick Lambert<br />
<br />
<br />
[http://rkyosd.blogspot.com/feeds/posts/default]<br />
name=Keyan Ren<br />
<br />
[http://awong79.blogspot.com/feeds/posts/default]<br />
name=Anthony Wong<br />
<br />
[http://jekyjaw.wordpress.com/category/open-source/feed]<br />
name=Yevgeniy Ivanchenko<br />
<br />
[http://raymondhung.wordpress.com/category/open-source/feed/]<br />
name=Raymond Hung<br />
<br />
[http://topheruppercut.wordpress.com/category/open-source/feed/]<br />
name=Christopher Cheung<br />
<br />
[https://saadism.wordpress.com/feed/]<br />
name=Saad Mohammad<br />
<br />
[http://slee142.blogspot.com/feeds/posts/default]<br />
name=Sangjin (Eric) Lee<br />
<br />
[http://dliscio.wordpress.com/feed]<br />
name=David Liscio<br />
<br />
[http://guandayu.wordpress.com/feed/]<br />
name=Dayu Guan<br />
<br />
[http://elonli.ca/category/sbr600/feed/]<br />
name=Elon Li<br />
<br />
<br />
[http://blog.carsonyong.com/?feed=rss2]<br />
name=Carson Yong<br />
<br />
[http://snaqvi3.wordpress.com/category/open-source/feed/]<br />
name=Saba Naqvi<br />
<br />
[http://burrellaramone.wordpress.com/category/open_source/feed/]<br />
name=Ramone Burrell<br />
<br />
[http://moussa1.wordpress.com/category/open-source/feed/]<br />
name=Moussa Tabcharani<br />
<br />
[http://roottothehead.blogspot.com/feeds/posts/default/-/CDOT]<br />
name=Jordan Cwang<br />
<br />
[http://diogogmt.wordpress.com/category/open-source/feed/]<br />
name=Diogo Golovanevsky Monteiro<br />
<br />
[http://www.anuragbhatnagar.com/category/open-source/feed/]<br />
name=Anurag Bhatnagar<br />
face=http://www.anuragbhatnagar.com/wp-content/uploads/2011/09/anurag1.png<br />
<br />
[http://withs.tumblr.com/tagged/OSD/rss]<br />
name=Jacky Siu<br />
<br />
[http://jjbmiller.wordpress.com/feed/]<br />
name=Jeff Miller<br />
<br />
[http://toomymon.wordpress.com/feed/]<br />
name=Tommy Cho Long Chor<br />
<br />
[http://jsilver999.wordpress.com/category/open-source/feed/]<br />
name=Jesse Silver<br />
<br />
[http://justintrobinson.wordpress.com/category/bigbluebutton/feed/]<br />
name=Justin Robinson<br />
<br />
[http://cchoo2.blogspot.com/feeds/posts/default]<br />
name=Chris Choo<br />
<br />
[http://teddychilai.wordpress.com/category/sbr600/feed/]<br />
name=Chi Hsun Lai<br />
<br />
[http://dsun20.wordpress.com/feed/]<br />
name=Dong Sun<br />
<br />
[http://alberttruong.wordpress.com/category/SBR600/feed/]<br />
name=Albert Truong<br />
<br />
[http://jessefulton.wordpress.com/category/SBR600/feed/]<br />
name=Jesse Fulton<br />
<br />
[http://ligangbory.wordpress.com/feed/]<br />
name=Gang Li<br />
<br />
[http://kliu39.wordpress.com/feed/]<br />
name=Kun Liu<br />
<br />
[http://mariabustoss.wordpress.com/feed/]<br />
name=Maria Bustos-Roman<br />
<br />
[http://kavisbr.blogspot.com/feeds/posts/default]<br />
name=Kavishankar Srivamathevan<br />
<br />
[http://namsbloging.blogspot.com/feeds/posts/default]<br />
name=Nam Nguyen<br />
<br />
[http://dsegree.wordpress.com/feed/]<br />
name=Daniel Segree<br />
<br />
[http://sajed481.wordpress.com/opensource/feed/]<br />
name=Mohammad Abdullah Sajed Shadani<br />
<br />
[http://asalwi123.wordpress.com/feed/]<br />
name=Aries Alwi<br />
<br />
[http://jmulwani.wordpress.com/feed/]<br />
name=Jayaditya Mulwani<br />
<br />
[http://sbr600blog.blogspot.com/feeds/posts/default]<br />
name=Andrew Greene<br />
<br />
[http://chadpilkey.wordpress.com/category/opensource/feed/]<br />
name=Chad Pilkey<br />
<br />
[http://ejtorre.blog.ca/feed/rss2/posts/]<br />
name=Eugene Torre<br />
<br />
[http://lynart.wordpress.com/category/CDOT/feed/]<br />
name=Vince Lee<br />
<br />
[http://stani.ca/?feed=rss2&cat=3]<br />
name=Robert Stanica<br />
<br />
[http://cdot-callaghan.posterous.com/rss.xml?tag=CDOT]<br />
name=Peter Callaghan<br />
<br />
[http://zaf1.wordpress.com/category/open-source/feed/]<br />
name=Shayan Zafar Ahmad<br />
<br />
[http://zyu26.wordpress.com/feed/]<br />
name=Zhiping Yu<br />
<br />
[http://stiversc.blogspot.ca/feeds/posts/default/-/OSD600]<br />
name=Michael Stiver-Balla<br />
<br />
[http://maximumou.blogspot.com/feeds/posts/default]<br />
name=Zhi Chang Ou<br />
<br />
[http://www.kypertrast.net/seneca/category/open-source/feed/]<br />
name=Michael Afidchao<br />
<br />
[http://epsilon812.wordpress.com/category/open-source/feed/]<br />
name=Rick Eyre<br />
<br />
[http://ayufidin.blogspot.ca/feeds/posts/default]<br />
name=Alon Yufidin<br />
<br />
[http://sudodamha.blogspot.com/feeds/posts/default]<br />
name=Ahmad Taychouri<br />
<br />
[http://amartinencosbr600.blogspot.com/feeds/posts/default]<br />
name=Andrei Martinenco<br />
<br />
[http://sbr600.tumblr.com/rss]<br />
name=Daniel Delidjakov<br />
<br />
[http://ashtramwasser.blogspot.ca/feeds/posts/default]<br />
name=Alina Shtramwasser<br />
<br />
[http://limed3.wordpress.com/category/open-source/feed/]<br />
name=Edwin Lim<br />
<br />
[http://caitpotter.blogspot.com/feeds/posts/default/-/open%20source] <br />
name=Dylan Potter<br />
<br />
[http://rlawrence5.wordpress.com/feed/]<br />
name=Ryan Lawrence<br />
<br />
[http://okhattab.wordpress.com/feed/]<br />
name=Omarr Khattab<br />
<br />
[http://aadavis1.blogspot.ca//feeds/posts/default]<br />
name=Alexander Davis<br />
<br />
[http://kdayalingam.wordpress.com/category/dpi908/feed]<br />
name=Kowrinanthan Dayalingam<br />
<br />
[http://jcqiu.wordpress.com/feed/]<br />
name=Jiecheng Qiu<br />
<br />
[http://mikeshutov.blogspot.com/feeds/posts/default/-/open-source]<br />
name=Mike Shutov<br />
<br />
[http://avru.wordpress.com/category/open-source/feed/]<br />
name=Anh Tran<br />
<br />
[http://kyle.barnhart.ca/feeds/posts/default/-/Open%20Source]<br />
name=Kyle Barnhart<br />
<br />
[http://gloriaip.wordpress.com/feed/]<br />
name=Gloria Ip<br />
<br />
[http://www.mandeepgarg.wordpress.com/feed/]<br />
name=Mandeep Garg<br />
<br />
[http://bharmidy.blogspot.ca/feeds/posts/default/-/open%20source]<br />
name=Bryce Harmidy<br />
<br />
[http://andrewow.wordpress.com/category/sbr600/feed/]<br />
name=Andrew Oatley-Willis<br />
<br />
[http://dima1086.blogspot.com/feeds/posts/default/-/Open%20Source]<br />
name=Dmytro Kostenyuk<br />
<br />
[http://hapombo.blogspot.ca/feeds/posts/default]<br />
name=Hugo Pombo<br />
<br />
[http://petepabs.wordpress.com/feed/]<br />
name=Peter Valerio<br />
<br />
<br />
[http://sabanane.wordpress.com/feed/]<br />
name=Japheth N.<br />
<br />
[http://rtang12.blogspot.ca/feeds/posts/default]<br />
name=Ruowen Tang<br />
<br />
[http://softwarebuildrun.wordpress.com/feed/]<br />
name=Rudolf R Janns<br />
<br />
[http://wkhan10.wordpress.com/feed]<br />
name=Waqas Khan<br />
<br />
[http://senecacd.wordpress.com/feed/]<br />
name=Seneca-CD Research Project<br />
<br />
</pre></div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Planet_CDOT_Feed_List&diff=65193Planet CDOT Feed List2011-06-07T18:06:31Z<p>Ladanzahir: /* Feeds */</p>
<hr />
<div>= Introduction =<br />
<br />
Seneca students and faculty working on open source related projects and research, as well as some faculty, students, and researchers from other institutions, use [http://zenit.senecac.on.ca/~chris.tyler/planet/ Planet CDOT] to aggregate their blogs. This page contains the information about who is blogging in [http://www.planetplanet.org/ Planet Feed Reader format] and serves as the feed configuration for the planet.<br />
<br />
If you do not have an existing blog, you can open a free account at [http://wordpress.com/ Wordpress.com] or [https://www.blogger.com/ Blogger.com] or you can set up your own blog software such as [http://www.s9y.org Serendipity].<br />
<br />
'''Note:''' Additions to the feed list will not take effect until they are merged into the Planet configuration, which is an automatic process scheduled at regular intervals. If you add a feed and do not see it picked up in the Planet within three hours, please check your feed entry carefully and then contact [[User:Chris Tyler|Chris Tyler]] .<br />
<br />
= Requirements =<br />
<br />
* Blog postings fed to the planet must conform to the [[Blog Guidelines]].<br />
* Feeds that are inactive for a significant period of time may get deleted from this list.<br />
<br />
= Using a Tagged/Category Feed =<br />
<br />
A tagged or category feed includes only articles that are tagged with particular keywords or placed in a particular topic category. This can be useful for sending only selected posts to the planet.<br />
<br />
These are the URL formats for tagged or category feeds on popular blogging services/software:<br />
<br />
* [http://www.wordpress.com Wordpress]: <code><nowiki>[http://</nowiki>''blog-user-name''.wordpress.com/category/''category-name''/feed/]</code><br />
* [http://blogger.com Blogger]: <code><nowiki>[http://</nowiki>''blog-user-name''.blogspot.com/feeds/posts/default/-/''category-name'']</code><br />
* [http://s9y.org Serendipity]: <code><nowiki>[http://</nowiki>''blog-main-url''/index.php?/feeds/categories/''cateogrynumber''-''categoryname'']</code><br />
<br />
= Feed Info Format =<br />
<br />
You can add your blog's [http://en.wikipedia.org/wiki/RSS_(file_format) RSS feed] at the end of the list below by specifying the following:<br />
<br />
# The URL to your blog's open source Atom or [http://en.wikipedia.org/wiki/RSS_(file_format) RSS Feed] (i.e., a category or tag). NOTE: Please do not put the URL to your blog -- use the URL for your feed. Please do not use the feed for your entire blog (unless your blog contains only open source-related postings). We only want open source related content.<br />
# Your name as you want it to appear in the list of names for the planet<br />
# Optionally, a URL to a [http://en.wikipedia.org/wiki/Hackergotchi hackergotchi] ([http://wouterverhelst.livejournal.com/21322.html how to]). Your picture should be an 65x85 PNG with a transparent background.<br />
<br />
<br />
= Feeds =<br />
<br />
<pre><br />
<br />
[http://ladanzahir.wordpress.com/category/CDOT/feed/]<br />
name=Ladan Zahiroleslam Zade<br />
<br />
<br />
[http://mschranz.wordpress.com/category/seneca_college/feed/]<br />
name=Matthew Schranz<br />
<br />
[http://www.spectakular.com/category/open-source/feed/]<br />
name=Simon Jung<br />
<br />
[http://jbuckley.ca/category/open-source/feed/]<br />
name=Jon Buckley<br />
<br />
[http://mbrzuzy.wordpress.com/category/open-source/feed/]<br />
name=Marcin Brzuzy<br />
<br />
[http://ben1amin.wordpress.com/category/seneca/feed/]<br />
name=Benjamin Chalovich<br />
<br />
[http://edghardest1.wordpress.com/category/open-source-topics/feed/]<br />
name=Ed Arvelaez<br />
<br />
[http://www.ashkansotoudeh.com/blog/?tag=oop344&feed=rss2]<br />
name=Ashkan Sotoudeh<br />
<br />
[http://dboddie46.wordpress.com/category/SBR600A/feed/]<br />
name=Derrick Boddie<br />
<br />
[http://aali83.blogspot.com/feeds/posts/default/-/oop344]<br />
name=Ahmad Ali<br />
<br />
[http://gr8can8dian.wordpress.com/category/sbr600/feed/]<br />
name=Lorin Soura<br />
<br />
[http://kirtonmike.wordpress.com/category/SBR600/feed/]<br />
name=Mike Kirton<br />
<br />
[http://fuzzux.wordpress.com/category/SBR600/feed/]<br />
name=Tim Furzer<br />
<br />
[http://nageyi.wordpress.com/feed/]<br />
name=Faisal Nageyi<br />
<br />
[http://KrazyDre.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Andrei Artamonov<br />
<br />
[http://mjcorsame.wordpress.com/feed/]<br />
name=Michael John Corsame<br />
<br />
[http://msbreezy12.wordpress.com/category/SBR/feed/]<br />
name=Chantell Mcintosh<br />
<br />
# Disabled 2011-04-28 - empty blog<br />
#[http://mrtait1.blogspot.com/feeds/posts/default/-/oop344]<br />
#name=Matthew Tait<br />
<br />
[http://brettvangennip.wordpress.com/category/sbr600/feed]<br />
name=Brett van Gennip<br />
<br />
[http://sbr600cabbott.blogspot.com/feeds/posts/default]<br />
name=Chris Abbott<br />
<br />
[http://kopay.wordpress.com/category/sbr600-win2011/feed]<br />
name=Pirathapan Sivalingam<br />
<br />
[http://mysnogorodsky.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Marina Ysnogorodsky<br />
<br />
[http://asa.veryusefulinfo.com/?feed=rss2]<br />
name=Ali Samimi<br />
<br />
# Disabled 2011-04-28 - empty blog<br />
#[http://coreyangus.blogspot.com/feeds/posts/default/-/oop344]<br />
#name = Corey Angus<br />
<br />
[http://wsong18.blogspot.com/feeds/posts/default/-/OOP344]<br />
name = Wei Song<br />
<br />
# Disabled 2011-04-28 - blog deleted<br />
#[http://kijeongkim.blogspot.com/feeds/posts/default]<br />
#name=Kijeong Kim<br />
<br />
[http://davidsosd60020102blog.blogspot.com/feeds/posts/default]<br />
name=David Takasaki<br />
<br />
[http://zwang98.blogspot.com/feeds/posts/default]<br />
name=Joe Wang<br />
<br />
[http://sbr700.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Jonathan Deni<br />
#face=https://techontherun.sslpowered.com/techontherun.ca/jonthumb.png<br />
<br />
[http://dgilloch.blogspot.com/feeds/posts/default]<br />
name=Daniel Gilloch<br />
<br />
[http://jmchen11.wordpress.com/feed/]<br />
name=Jianming Chen<br />
<br />
[http://paulfedora.wordpress.com/tag/cdot/feed/]<br />
name=Paul Whalen<br />
<br />
[http://dmchisho.wordpress.com/feed/]<br />
name=David Chisholm<br />
<br />
[http://pokerface3.blogspot.com/feeds/posts/default/-/SBR?alt=rss]<br />
name=David Cabral<br />
<br />
[http://zbhuang1.blogspot.com/feeds/posts/default/-/open%20source]<br />
name=Zhibin Huang<br />
<br />
[http://sidsbr.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Sadiki Latty<br />
<br />
[http://orel60.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Or-el Mousaffi<br />
<br />
[http://aryafarzan.wordpress.com/category/OOP344/feed/]<br />
name=Arya Farzan<br />
<br />
[http://dsventura.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Dan Ventura<br />
<br />
[http://cadecairos.blogspot.com/feeds/posts/default/-/open-source]<br />
name=Christopher DeCairos<br />
<br />
[http://acfunktron.blogspot.com/feeds/posts/default]<br />
name=Anton Chan<br />
<br />
[http://adaniel3.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Arlene Daniel<br />
<br />
[http://tyrant911-processingdotjs.blogspot.com/feeds/posts/default/-/processing.js]<br />
name=Alex Londono<br />
<br />
# Disabled 2009-11-13 by Chris Tyler <chris.tyler@senecac.on.ca> (ctyler on IRC)<br />
# Ausley: Contact me to discuss before re-enabling.<br />
#[http://ausleyj.blogspot.com/feeds/posts/default]<br />
#name=Ausley Johnson<br />
<br />
[http://arminoop344.blogspot.com/feeds/posts/default]<br />
name=Armin Kumarshellah<br />
<br />
[http://cloudscorpion.blogspot.com/feeds/posts/default/-/OOP344]<br />
name=Joseph Hughes<br />
<br />
[http://travisrawn.blogspot.com/feeds/posts/default]<br />
name=Travis Rawn<br />
<br />
[http://jmpiltz.blogspot.com/feeds/posts/default]<br />
name=Jonathan Piltz<br />
<br />
[http://andrewgrimo.wordpress.com/category/open-source/feed/]<br />
name=Andrew Grimo<br />
<br />
[http://apvsbr700.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Alex Vlahopoulos<br />
#face=https://techontherun.sslpowered.com/techontherun.ca/alexthumb.png<br />
<br />
[http://asalga.wordpress.com/category/open-source/feed/]<br />
name=Andor Salga (asalga)<br />
<br />
[http://jabhad.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Mohamed Aden<br />
<br />
[http://jonathandeni.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Jonathan Deni<br />
#face=https://techontherun.sslpowered.com/techontherun.ca/jonthumb.png<br />
<br />
[http://manoutoftime.wordpress.com/category/open-source/feed/]<br />
name=Konstantin Novichikhin<br />
<br />
[http://scorchedicee.wordpress.com/category/Seneca/feed/]<br />
name=Adam Sone<br />
<br />
[http://murraysaul.wordpress.com/feed/]<br />
name=Murray Saul<br />
<br />
[http://xwn740arcadeproject.blogspot.com/feeds/posts/default]<br />
name=Arcade Project - LUX Group@<br />
#face=http://matrix.senecac.on.ca/~mpaivaneto/ourbaby.png<br />
<br />
[http://crashopensource.blogspot.com/feeds/posts/default/-/open-source]<br />
name=Lukas Blakk (lsblakk)<br />
#face=http://avnerd.tv/sharedFiles/lukas_hackergotchi.png<br />
<br />
[http://nashutzu.blogspot.com/feeds/posts/default]<br />
name=George Popescu (GeorgeP)<br />
<br />
[http://blog.chris.tylers.info/index.php?/feeds/categories/20-Seneca-Planet.rss]<br />
name=Chris Tyler (ctyler)<br />
face=http://zenit.senecac.on.ca/~chris.tyler/chris_tyler_hackergotchi_4a.png<br />
<br />
[http://vocamus.net/dave/?feed=rss2&category_name=Seneca]<br />
name=David Humphrey<br />
<br />
[http://gratnam1.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Gajendran Ratnam (gratnam1)<br />
<br />
[http://senecajon.blogspot.com/feeds/posts/default]<br />
name=Jonathan Cheung (jcheung23)<br />
<br />
# Disabled 2011-04-28 - blog was removed<br />
#[http://blog.markparuzel.com/feed/]<br />
#name=Mark Paruzel<br />
<br />
[http://mmszuto.blogspot.com/feeds/posts/default]<br />
name=Michael Szutu<br />
<br />
[http://lsdaly.blogspot.com/feeds/posts/default]<br />
name=Louis Daly (lsdaly)<br />
<br />
# Disabled 2009-01-25 due to 404's (domain expired)<br />
#[http://www.foobartastic.com/feed/]<br />
#name=Tom Aratyn<br />
<br />
[http://bhearsum.blogspot.com/feeds/posts/default/-/seneca]<br />
name=Ben Hearsum<br />
<br />
# Following feed is invitation-only. Disabled 2010-09-23 CTyler<br />
#[http://www.jyzyy.blogspot.com/feeds/posts/default/-/opensource]<br />
#name=Jyoti<br />
<br />
# Re-enabled 2011-04-29 - new blog URL<br />
# Disabled 2009-09-15 due to 404's (site rearranged?)<br />
[http://tea.cesaroliveira.net/archives/tag/seneca/feed]<br />
name=Cesar Oliveira<br />
<br />
[http://r3ap3r.wordpress.com/category/seneca/feed]<br />
name=Brandon Collins<br />
<br />
# Disabled 2011-04-28 - blog was deleted<br />
#[http://jrgoncal.blogspot.com/feeds/posts/default]<br />
#name=Justin Goncalves (jrgoncal)<br />
#face=http://img517.imageshack.us/img517/9865/bearzp5.jpg<br />
<br />
# Disabled 2011-04-28 - blog is now private<br />
#[http://tlo5.blogspot.com/feeds/posts/default]<br />
#name=Tommy Lo (tlo5)<br />
<br />
[http://armenzg.blogspot.com/feeds/posts/default/-/open%20source]<br />
name=Armen Zambrano G. (armenzg)<br />
<br />
[http://mikemoz.blogspot.com/feeds/posts/default/-/Open%20Source]<br />
name=Michael Mullin<br />
<br />
[http://mikemoz.blogspot.com/feeds/posts/default/-/Mozilla_GFX]<br />
name=Michael Mullin<br />
<br />
# Returned 410 on 2008-09-13 - disabled CTyler<br />
#[http://rueenfiez.wordpress.com/category/open-source/feed/]<br />
#name=Rueen Fiez<br />
<br />
# Returning 404 on 2008-09-13 - disabled CTyler<br />
#[http://jsafavi.wordpress.com/category/open-source/feed/]<br />
#name=Jason Safavi<br />
<br />
[http://vlam6.wordpress.com/category/open-source/feed/]<br />
name=Vincent Lam<br />
<br />
[http://dejant.blogspot.com/feeds/posts/default]<br />
name=Dejan Tolj<br />
<br />
[http://shivaris.blogspot.com/feeds/posts/default/-/OSD600]<br />
name=Hien Huynh<br />
<br />
[http://raynrant.blogspot.com/feeds/posts/default]<br />
name=Andrew Raynier (JM)<br />
face=http://zenit.senecac.on.ca/wiki/imgs/Hackergotchi.png<br />
<br />
[http://vijeysdps909.blogspot.com/feeds/posts/default]<br />
name=Vijey Bala<br />
<br />
[http://sedejong.blogspot.com/feeds/posts/default]<br />
name=Shomar Dejonge<br />
<br />
[http://dbaranski.wordpress.com/category/open-source/feed/]<br />
name=Dominic Baranski<br />
<br />
#[http://crashopensource.wordpress.com/category/open-source/feed/]<br />
#name=Lukas Blakk<br />
<br />
[http://kmsingh.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Kerry M. Singh<br />
<br />
[http://tjduavis.wordpress.com/category/open-source/feed/]<br />
name=Timothy Duavis<br />
<br />
# Disabled 2011-04-28 - entire website is missing<br />
#[http://ashughes.com/?q=taxonomy/term/2/0/feed]<br />
#name=Anthony Hughes<br />
<br />
[http://opensourcekennethlee.blogspot.com/feeds/posts/default]<br />
name=Kenneth Lee<br />
<br />
[http://cleung.wordpress.com/category/Seneca/feed/]<br />
name=Catherine Leung<br />
<br />
[http://dtheosab.wordpress.com/category/open-source/feed/]<br />
name=Daino Theosabrata<br />
<br />
# This is my old blog<br />
[http://simon-jung.blogspot.com/feeds/posts/default]<br />
name=Simon Jung (old)<br />
<br />
[http://aeraj.blogspot.com/feeds/posts/default/-/open%20source]<br />
name=AJ Rehman<br />
<br />
[http://xrayon.blogspot.com/feeds/posts/default]<br />
name=Fima Kachinski<br />
<br />
[http://littlesvr.ca/grumble/category/safeforseneca/feed/]<br />
name=Andrew Smith<br />
<br />
[http://littlesvr.ca/masters/feed]<br />
name=Andrew Smith (master's)<br />
<br />
[http://jbopensrc.wordpress.com/category/open-source/feed]<br />
name=Jesse Buchanan<br />
<br />
[http://ayhfung.blogspot.com/feeds/posts/default]<br />
name=Andrew Fung<br />
<br />
# Returned 404 on 2008-09-13 - disabled CTyler<br />
#[http://sloose.wordpress.com/category/open-source/feed/]<br />
#name=Peter Ljubanovic<br />
<br />
[http://mozcoz.blogspot.com/feeds/posts/default/-/Open%20Source]<br />
name=Amit Gundu<br />
<br />
# Changed CTyler 2009-02-12 from [http://www.blogger.com/feeds/15922666655846514311/blogs]<br />
[http://dsmukherji.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Devashish<br />
<br />
[http://yhan11.wordpress.com/category/open-source/feed]<br />
name=Yongsheng Han<br />
<br />
[http://peter.sykokillers.com/category/open-source/feed/]<br />
name=Peter Chan<br />
<br />
[http://www.c3dl.org/index.php/category/c3dl-dev/feed]<br />
name=Seneca Canvas3D Team<br />
<br />
# Updated 2011-04-28 - corrected feed URL<br />
[http://peterevanoff.wordpress.com/category/open-source/feed/]<br />
name=Peter Evanoff<br />
<br />
# Disabled 2011-04-28 - flagged as a malware-loaded site by Google<br />
<br />
#[http://radoye.net1zen.com/wp-rss2.php?cat=3]<br />
#name=Radovan Nesic<br />
<br />
[http://blog.cresencia.ca/category/open-source/osd600/feed/]<br />
name=Joseph Cresencia<br />
<br />
[http://bertenshaw.blogspot.com/feeds/posts/default]<br />
name=David Bertenshaw<br />
<br />
[http://ljubomirgorscak.blogspot.com/feeds/posts/default]<br />
name=Ljubomir Gorscak<br />
<br />
[http://sameropensource.blogspot.com/feeds/posts/default]<br />
name=Samer Ziadeh (samer)<br />
<br />
# Following feed not working and temporarily disabled<br />
# 2010-09-23 by CTyler<br />
#[http://jamesboston.ca/cms/taxonomy/term/1/0/feed]<br />
#name=James Boston<br />
#face=http://jamesboston.ca/hackergotchi.png<br />
<br />
[http://dailypackage.fedorabook.com/index.php?/feeds/index.rss2]<br />
name=Fedora Daily Package<br />
<br />
[http://oooblog.fardad.com/feeds/posts/default/-/Seneca]<br />
name=Fardad Soleimanloo<br />
<br />
[http://seneblog.fardad.com/feeds/posts/default]<br />
name=Fardad Soleimanloo<br />
<br />
[http://selmys.wordpress.com/category/opensource/feed]<br />
name=John Selmys<br />
face=http://cs.senecac.on.ca/~selmys/john_selmys_hackergotchi.png<br />
<br />
[http://pconstantino.wordpress.com/feed]<br />
name=Patricia Constantino<br />
<br />
[http://bombshelter13.blogspot.com/feeds/posts/default]<br />
name=Gregory Masseau<br />
#face=http://matrix.senecac.on.ca/~gjmasseau/userpic.jpg<br />
<br />
[http://zadkielm.blogspot.com/feeds/posts/default/-/open%20source]<br />
name=Ezadkiel Marbella<br />
<br />
[http://blog.sidkalra.com/category/opensource/feed]<br />
name=Sid Kalra<br />
<br />
[http://pplam3.blogspot.com/feeds/posts/default]<br />
name=Patrick Lam<br />
<br />
# Disabled 2011-04-28 - blog is now private<br />
#[http://twlai1.blogspot.com/feeds/posts/default]<br />
#name=Tony Lai<br />
<br />
[http://dee132.blogspot.com/feeds/posts/default/-/seneca]<br />
name=Chris Bishop<br />
<br />
# Updated 2011-04-28 - updated feed URL<br />
[http://zghansar.wordpress.com/category/open-source/feed/]<br />
name=Zaid Ghansar<br />
face=http://www.alhudainstitute.ca/zaid/z.png<br />
<br />
[http://aaronmt.com/?feed=rss2]<br />
name=Aaron Train<br />
face=http://matrix.senecac.on.ca/~amtrain/other/mypic.png<br />
<br />
[http://scottosd.blogspot.com/feeds/posts/default/-/Open%20Source/]<br />
name=Scott Lunel<br />
<br />
# Updated 2009-04-16, new blog. - scarter4<br />
# Disabled 2009-11-27 due to wrong feed URL<br />
#[http://scarter4.wordpress.com/category/seneca/]<br />
#name=Stephen Carter<br />
<br />
# Disabled 2009-01-23 CTyler due to 404s<br />
#[http://shdinis.blogspot.com/feeds/posts/default]<br />
#name=Shawn Dinis<br />
<br />
[http://belligero.org/index.php?option=com_content&view=section&id=1&format=feed&type=rss]<br />
name=Jason Tarka<br />
<br />
# Updated 2011-04-28 - no more tag, but still Seneca related<br />
[http://petermcintyre.wordpress.com/feed/]<br />
name=Peter McIntyre<br />
<br />
[http://vesperrin.blogspot.com/feeds/posts/default/-/open%20source]<br />
name=Leonard Lee (vesper)<br />
<br />
[http://jsdoodnauth.wordpress.com/category/open-source/feed/]<br />
name=Joshua Doodnauth<br />
<br />
[http://johnhford.blogspot.com/feeds/posts/default/-/Open%20Source]<br />
name=John Ford (John64)<br />
<br />
[http://mohaksblog.blogspot.com/feeds/posts/default]<br />
name=Mohak Vyas<br />
#face=http://matrix.senecac.on.ca/~mdvyas/MohakVyas.png<br />
<br />
[http://pdirezze.blogspot.com/feeds/posts/default]<br />
name=Paul DiRezze<br />
<br />
# Following link no longer valid. Disabled 2010-09-23 CTyler<br />
#[http://www.ndaversa.com/category/open-source/feed]<br />
#name=Nino D'Aversa<br />
<br />
[http://miltonpaiva.wordpress.com/feed/]<br />
name=Milton Paiva<br />
#face=http://matrix.senecac.on.ca/~mpaivaneto/orkut.png<br />
<br />
[http://de-luxer.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Nestor Chan<br />
#face=http://matrix.senecac.on.ca/~tnchan/n516840997_9173.PNG<br />
<br />
[http://varinderjhand.wordpress.com/feed/]<br />
name=Varinder Singh <br />
<br />
[http://ajhooper.blogspot.com/feeds/posts/default]<br />
name=Aaron Hooper<br />
<br />
[http://nadavid.blogspot.com/feeds/posts/default]<br />
name=Neil David<br />
<br />
[http://cdpatel1.blogspot.com/feeds/posts/default]<br />
name=Chinmay Patel<br />
#face=http://www.geocities.com/chinmay_patel@ymail.com/chinmay.jpg<br />
<br />
[http://jvalianes.blogspot.com/feeds/posts/default]<br />
name=Jesse Valianes<br />
<br />
[http://bbarcick.blogspot.com/feeds/posts/default/-/Open%20Source]<br />
name=Bartosz Barcicki<br />
<br />
[http://heidenreich.wordpress.com/tag/seneca-college/feed/]<br />
name=Michal Heidenreich<br />
<br />
[http://kezhong.wordpress.com/feed/atom/]<br />
name=Kezhong Liang <br />
<br />
[http://wfred.wordpress.com/category/open-source/feed/]<br />
name=Fred Wang<br />
<br />
[http://jsinghfoss.wordpress.com/category/spring-framework/feed/]<br />
name=Jatinder Singh<br />
<br />
[http://rparsi.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Rahi Parsi<br />
<br />
# Changed 2011-04-28 - missing a capital "S" from Seneca to display feed<br />
[http://aaronrey15.blogspot.com/feeds/posts/default/-/Seneca]<br />
name=Aaron Chan<br />
<br />
# Disabled 2011-04-28 - posts were deleted, empty feed<br />
#[http://flashalive.wordpress.com/category/Open%20Source/feed/]<br />
#name=Ryan Wang<br />
<br />
[http://kvuhome.blogspot.com/feeds/posts/default/-/Open%20Source]<br />
name=Khanh Vu<br />
<br />
[http://daeseonmoon.wordpress.com/category/open-source/feed/]<br />
name=Daeseon Moon<br />
<br />
[http://abraini.wordpress.com/category/seneca/feed/]<br />
name=Andrew Braini<br />
<br />
[http://minicheong.blogspot.com/feeds/posts/default]<br />
name=Frankie Law<br />
<br />
# Following feed changed from http://www.heyqule.net/blog/tech/oss/feed<br />
# on 2010-09-23 by CTyler.<br />
[http://www.heyqule.net/taxonomy/term/44/0/feed]<br />
name=Allen JF Xie (heyqule)<br />
<br />
[http://farhadnorouzi.blogspot.com/feeds/posts/default]<br />
name=Farhad Norouzi<br />
<br />
[http://jdeport.wordpress.com/category/software-development/open-source/feed/]<br />
name=John Dang<br />
<br />
[http://pliu.wordpress.com/category/open-source/feed/]<br />
name=Peter Liu<br />
<br />
# Feed not working - temporarily disabled 2010-09-23 CTyler<br />
#[http://www.jerrypau.ca/?feed=rss2&cat=3]<br />
#name=Jerry Pau<br />
#face=http://www.jerrypau.ca/blog-face-1.png<br />
<br />
[http://blog.wikiscraps.com/feeds/posts/default/-/oss]<br />
name=M. Mead Armsby (mead)<br />
<br />
[http://paritosha.blogspot.com/feeds/posts/default]<br />
name=Paritosh Aggarwal(paritosh1010)<br />
<br />
# Private blog. Disabled 2010-09-23 CTyler.<br />
#[http://myblog110.wordpress.com/category/open-source/feed]<br />
#name=Tahereh<br />
<br />
# Disabled 2011-04-28 - empty feed, all posts were removed<br />
#[http://challenger110.wordpress.com/category/software-development/open-source/censored/feed/]<br />
#name=Davoud Salahi Rad<br />
<br />
[http://wb-os.blogspot.com/feeds/posts/default]<br />
name=Le Yang<br />
<br />
[http://garykwong.wordpress.com/category/education/feed/]<br />
name=Gary Kwong (nth10sd)<br />
<br />
[http://yuenhoe.co.cc/blog/category/mozilla/feed/]<br />
name=Lim Yuen Hoe (moofang)<br />
<br />
# Disabled 2011-04-27 - empty feed, needs to be udpated<br />
#[http://tonychestnut.wordpress.com/category/mozilla/ubiquity/feed/]<br />
#name=Vu Dinh The (tonyvu)<br />
<br />
[http://opensourceproject.wordpress.com/category/open-source/feed/]<br />
name=Nabeel Khan (nkhan26)<br />
<br />
# Disabled 2011-04-27 - suspended domain<br />
#[http://solfu.net/tech/category/personas-for-thunderbird/feed/]<br />
#name=Yaoquan (seith)<br />
<br />
[http://xiajunshi.wordpress.com/category/open-source/feed/]<br />
name=Shelley Shi<br />
<br />
[http://hendrikinmozilla.wordpress.com/feed/]<br />
name=Hendrik<br />
<br />
[http://t3rrychan.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Terry Chen (jchen124)<br />
<br />
[http://blog.bchao.ca/feeds/posts/default?alt=rss]<br />
name=Boris Chao<br />
<br />
[http://ahiltssbr700.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Adam Hilts<br />
<br />
[http://ysasaki600.wordpress.com/feed/]<br />
name=Yu Sasaki<br />
<br />
[http://enderstruth.wordpress.com/category/open-source/feed/]<br />
name=Roger Dicke<br />
<br />
[http://wobblyretroaction.blogspot.com/feeds/posts/default/-/Open%20source]<br />
name=Matthew Lam<br />
<br />
[http://asydik.wordpress.com/category/professional/open-source/feed/]<br />
name=Mickael Medel (aSydiK)<br />
<br />
[http://cwd89.blogspot.com/feeds/posts/default/-/project]<br />
name=Carl Desautels<br />
<br />
[http://rselby-oop344.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Remington Selby<br />
<br />
[http://mikey-osd600a.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Michael Dennis<br />
<br />
# Disabled 2011-04-27 - empty blog<br />
#[http://tjprogramming.blogspot.com/feeds/posts/default/-/seneca]<br />
#name=Timothy Catibog<br />
<br />
[http://horndavid.blogspot.com/feeds/posts/default?alt=rss]<br />
name=David Horn<br />
<br />
[http://annasob.wordpress.com/feed/]<br />
name=Anna Sobiepanek<br />
<br />
[http://drozhkov.blogspot.com/feeds/posts/default/-/seneca]<br />
name=Dmitriy Rozhkov<br />
<br />
[http://www.hodgin.ca/?feed=rss2&cat=4]<br />
name=Daniel Hodgin<br />
<br />
[http://buddhatron.wordpress.com/category/OSD600/feed/]<br />
name=Buddhatron<br />
<br />
[http://xderick.blogspot.com/feeds/posts/default/-/OSD]<br />
name=Yong Hong<br />
<br />
# This next link does not lead to an RSS or Atom feed. Disabled 2009-10-25 by CTyler.<br />
#[http://hoonkoon.blogspot.com/2009/09/oop344.html]<br />
#name=Taehoon Kim<br />
<br />
[http://s2000c.blogspot.com/feeds/posts/default/-/OOP344]<br />
name=Sunny Chau<br />
<br />
# This next link does not lead to an RSS or Atom feed. Disabled 2009-10-25 by CTyler.<br />
#[http://s2000c.blogspot.com/2009/09/oop344c.html]<br />
#name=Sunny Chau<br />
<br />
[http://kxu9.blogspot.com/feeds/posts/default]<br />
name=Kai Xu<br />
<br />
[http://oop-era.blogspot.com/feeds/posts/default]<br />
name=Eric Austerberry<br />
<br />
[http://docsage.blogspot.com/feeds/posts/default/-/OOP344]<br />
name=Eric Dell<br />
<br />
[http://ehren.wordpress.com/category/Seneca/feed/]<br />
name=Ehren Metcalfe<br />
<br />
[http://bsmith19.wordpress.com/category/Seneca/feed/]<br />
name=Brandon Smith<br />
<br />
[http://dcucereavii.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Diana Cucereavii<br />
<br />
# Disabled 2011-04-27 - site unreachable<br />
#[http://www.savantosis.com/?feed=rss2&cat=3]<br />
#name=Justin Robertson<br />
<br />
[http://paul-oop344.blogspot.com/feeds/posts/default/]<br />
name=Paul Repasi<br />
<br />
[http://istessema.wordpress.com/category/oop344/feed/]<br />
name=Iyosias Tessema<br />
<br />
[http://nedape.blogspot.com/feeds/posts/default]<br />
name=Neda Pezeshki<br />
<br />
[http://justletmepassoop344.blogspot.com/feeds/posts/default]<br />
name=Brian Parreno<br />
<br />
[http://dliu53.wordpress.com/category/open-source/feed/]<br />
name=Donghui Liu<br />
<br />
# Disabled 2011-04-27 - site not found<br />
#[http://oopblog.tdotshack.net/feeds/posts/default/-/OOP344]<br />
#name=Ryan Alexander<br />
<br />
[http://oop344ylseow.blogspot.com/feeds/posts/default]<br />
name=Yip Lim, Seow<br />
<br />
[http://mercedes-oop344.blogspot.com/feeds/posts/default]<br />
name=Suwon An<br />
<br />
[http://dtychshenko.blogspot.com/feeds/posts/default/-/OOP344]<br />
name=Dmitriy Tychshenko<br />
<br />
[http://victran.blogspot.com/feeds/posts/default/-/OOP344]<br />
name=Victor Tran<br />
<br />
# Changed 2011-04-27 - updated feed URL to proper<br />
[http://krazyazn.blogspot.com/feeds/posts/default]<br />
name=Michael Lin<br />
<br />
[http://xshi18.blogspot.com/feeds/posts/default]<br />
name=Xiaozhe Shi<br />
<br />
[http://feihong-xiong.blogspot.com/feeds/posts/default]<br />
name=Feihong Xiong<br />
<br />
[http://orbitalstation.wordpress.com/category/programming/feed/]<br />
name=Hasan Kamal<br />
face=http://matrix.senecac.on.ca/~hkamal-al-deen/images/Exclaim65x85.png<br />
<br />
[http://hduan2.wordpress.com/feed/]<br />
name= Haoliang Duan<br />
<br />
[http://anastasias-myblog.blogspot.com/feeds/posts/default/-/OOP344]<br />
name= Anastasia Semionova<br />
<br />
[http://franksun123.blogspot.com/feeds/posts/default/]<br />
name= Dong Sun<br />
<br />
[http://rkyoop344.blogspot.com/feeds/posts/default/]<br />
name=Keyan Ren<br />
<br />
[http://ctran13.blogspot.com/feeds/posts/default/-/oop344]<br />
name=Chi-Lea Tran<br />
<br />
[http://szymonsoop.blogspot.com/feeds/posts/default/]<br />
name= Szymon Ahmed<br />
<br />
[http://ywang268.blogspot.com/feeds/posts/default/]<br />
name=Yu Wang<br />
<br />
[http://wangcong422.blogspot.com/feeds/posts/default/]<br />
name=Cong Wang<br />
<br />
[http://dennyp.wordpress.com/category/Seneca/feed/]<br />
name=Denny Papagiannidis<br />
<br />
# Blog not found. Disabled 2010-09-23 CTyler.<br />
#[http://java-chinmay.blogspot.com/feeds/posts/default]<br />
#name= Chinmay Patel<br />
<br />
[http://sergedoescoding.blogspot.com/feeds/posts/default/]<br />
name= Sergiu Ecob<br />
<br />
# Disabled 2011-04-27 - blog deleted<br />
#[http://satijas.wordpress.com/category/OOP344/feed/]<br />
#name=Sasha Atijas<br />
<br />
# 404. Disabled 2010-09-23 CTyler.<br />
#[http://auzix.com/seneca/?feed=rss2]<br />
#name=Tyler Hackwood<br />
<br />
#[http://starbuck-blog.blogspot.com/feeds/posts/default]<br />
#name=Verity Li<br />
<br />
[http://gkrilov.blogspot.com/feeds/posts/default]<br />
name=Greg Krilov<br />
<br />
[http://qinzhi2001.blogspot.com/feeds/posts/default]<br />
name=David Chen<br />
<br />
[http://tchen-oop344.blogspot.com/feeds/posts/default]<br />
name=Terence Chen<br />
<br />
[http://opp344-yxue.blogspot.com/feeds/posts/default]<br />
name=Yong Xue<br />
# Disabled 2011-04-28 - had 2 other duplicate feeds<br />
# http://opp344-yxue.blogspot.com/feeds/posts/default/-/seneca<br />
# http://opp344-yxue.blogspot.com/feeds/posts/default/-/OOP344<br />
<br />
[http://ttsuji1.blogspot.com/feeds/posts/default]<br />
name=Trevor Tsuji<br />
<br />
[http://oyoung4.blogspot.com/feeds/posts/default]<br />
name=Oliver Young<br />
<br />
[http://minyxo.blogspot.com/feeds/posts/default/-/Open%20Source]<br />
name=Edward Sin<br />
<br />
# Blog not found - disabled 2010-09-23 CTyler<br />
#[http://oop344f09-niki.blogspot.com/feeds/posts/default]<br />
#name=Niki Simmalavong<br />
<br />
[http://jdbcdps.blogspot.com/feeds/posts/default]<br />
name=Julia Vasserman<br />
<br />
[http://shunyao-cpa.blogspot.com/feeds/posts/default]<br />
name=Shun Yao Zhang<br />
<br />
# Disabled 2009-11-27 due to 500's on feed link<br />
# Re-enabled 2011-04-27 - incorrect URL format fixed<br />
[http://oop344ylseow.blogspot.com/feeds/posts/default]<br />
name=Yip Lim Seow<br />
<br />
[http://capereir.wordpress.com/feed/]<br />
name=Chris Pereira<br />
<br />
[http://dev-blog.zerogin.com/category/opensource/feed/]<br />
name=Tom Wisniewski (t0mmyw)<br />
<br />
# Disabled 2011-04-27 - empty feed, rest of blog is not related<br />
#[http://majorbludd.wordpress.com/category/school/feed/]<br />
#name=Michael Dawson<br />
<br />
[http://cdnpadawan.wordpress.com/feed/]<br />
name=Matthew Daniels<br />
<br />
[http://processingjs.org/blog/?feed=rss2]<br />
name=Processing.js Blog<br />
<br />
[http://dseifried.wordpress.com/category/school/feed/]<br />
name=David Seifried<br />
<br />
[http://tandemwebdesign.ca/blog/?feed=rss2&cat=3]<br />
name=Matthew Adams<br />
<br />
[http://s-aleinikov.blog.ca/feed/atom/posts/]<br />
name=Sergey Aleinikov<br />
<br />
[http://wfchen2010.blogspot.com/feeds/posts/default]<br />
name=Wen Fang Chen<br />
<br />
[http://donna-oberes.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Donna Oberes<br />
<br />
[http://carolynwoodley.blogspot.com/feeds/posts/default]<br />
name=Carolyn Woodley<br />
<br />
[http://rocketpants.blog.ca/feed/rss2/posts/]<br />
name=Christopher Cheung<br />
<br />
[http://shengwei-seneca.blogspot.com/feeds/posts/default]<br />
name=Shengwei Wang<br />
<br />
[http://zakoop344.blogspot.com/feeds/posts/default]<br />
name=Wei Tong<br />
<br />
[http://gtawaf.blogspot.com/feeds/posts/default/-/Seneca]<br />
name=Gamal Tawaf <br />
<br />
[http://rift-tlosam.blogspot.com/feeds/posts/default/-/seneca]<br />
name=Brendan McDorman<br />
<br />
[http://hdc23.wordpress.com/category/OOP344/feed]<br />
name=Dachuan Huang<br />
<br />
# Disabled 2011-04-27 - blank feed, aged blod<br />
#[http://qwu26.blogspot.com/feeds/posts/default/-/OOP344]<br />
#name=Qingxi Wu<br />
<br />
# Disabled 2011-04-27 - blank blog<br />
#[http://lwang162.blogspot.com/feeds/posts/default/-/OOP344]<br />
#name=LianHe Wang<br />
<br />
# Disabled 2011-04-27 - blank blog, aged<br />
#[http://bmcohen.blogspot.com/feeds/posts/default/-/seneca]<br />
#name=Bryan Cohen<br />
<br />
[http://feliploko.wordpress.com/category/seneca/feed]<br />
name=Felipe de Oliveira<br />
<br />
# Following feed reports invalid content type.<br />
# Disabled 2010-09-23 CTyler<br />
#[http://lwang168.blogspot.com/feeds/posts/-/oop344]<br />
#name=Liang Wang<br />
<br />
[http://shunyao-cpa.blogspot.com/feeds/posts/default]<br />
name=shun yao zhang<br />
<br />
[http://galewis.blogspot.com/feeds/posts/default]<br />
name=Gustone Lewis<br />
<br />
[http://hmo6.blogspot.com/feeds/posts/default]<br />
name=Mo Hsiu Mei<br />
<br />
[http://derekambrose.blogspot.com/feeds/posts/default/-/open%20source]<br />
name=Derek Ambrose<br />
<br />
[http://scottdowne.wordpress.com/category/open-source/feed/]<br />
name=Scott Downe<br />
<br />
# Disabled 2011-04-27 - blog deleted<br />
#[http://anthonyisgood.blogspot.com/feeds/posts/default/-/open%20source]<br />
#name = Anthony Alves<br />
<br />
[http://jjleeos.blogspot.com/feeds/posts/default]<br />
name = Jeffrey Lee<br />
<br />
[http://harjinderv.tumblr.com/tagged/Open_Source/rss]<br />
name = Harjinder Virdi<br />
<br />
[http://cldenobrega.wordpress.com/category/open-source/feed/]<br />
name = Crystal de Nobrega (cldenobrega)<br />
<br />
[http://lchen97.blogspot.com/feeds/posts/default]<br />
name=Chris Chen<br />
<br />
# Parked domain. Disabled 2010-09-23 CTyler<br />
#[http://hotweiss.lifeflayer.com/?feed=atom]<br />
#name=Tianqi Liu<br />
<br />
[http://oleg-oop.blogspot.com/feeds/posts/default]<br />
name=Aleh Pliats<br />
<br />
[http://88mishok.blogspot.com/feeds/posts/default]<br />
name=Francois Des Jarlais<br />
<br />
[http://bikarin.blogspot.com/feeds/posts/default]<br />
name=Irina Balzamova<br />
<br />
[http://mashhaque.blogspot.com/feeds/posts/default]<br />
name=Mashfique Haque<br />
<br />
[http://yxue11.blogspot.com/feeds/posts/default]<br />
name=Yong Xue<br />
<br />
[http://tdao75.blogspot.com/feeds/posts/default]<br />
name=Thanh Dao<br />
<br />
[http://minooz.wordpress.com/category/CDOT/feed/]<br />
name=Minoo Ziaei<br />
<br />
[http://gbatumbya.wordpress.com/category/seneca/cdot/feed/]<br />
name=Grace Simon Batumbya<br />
<br />
[http://sonnilion.wordpress.com/feed/]<br />
name=Matt Postill<br />
<br />
[http://acchung1.blogspot.com/feeds/posts/default/-/oop344]<br />
name=Alex Chun Yang Chung<br />
<br />
[http://hckim.wordpress.com/category/open-source/feed/]<br />
name=Han Chul Kim<br />
<br />
[http://xizhangblog.blogspot.com/feeds/posts/default/-/oop344]<br />
name=Xi Zhang<br />
<br />
# Modified 2011-04-27 - changed from blank category<br />
[http://lwu11.blogspot.com/feeds/posts/default]<br />
name=Ling Wu<br />
<br />
[http://jasonquan.wordpress.com/category/OOP344/feed/]<br />
name=Jason Quan<br />
<br />
[http://myoop344blog.blogspot.com/feeds/posts/default/]<br />
name=Xiongwen LU<br />
<br />
[http://0zzym.wordpress.com/feed]<br />
name=Osman Mirza<br />
<br />
[http://adgezaza.posterous.com/rss.xml?tag=open%20source]<br />
name=Adrian Maurer<br />
<br />
[http://kumailhabib.blogspot.com/feeds/posts/default]<br />
name=Kumail Habib<br />
<br />
[http://imadorki3.blogspot.com/feeds/posts/default]<br />
name=Robin Co<br />
<br />
[http://danapao026.blogspot.com/feeds/posts/default]<br />
name=Don Armin Napao<br />
<br />
[http://cgm087.blogspot.com/feeds/posts/default/-/CDOT]<br />
name=Christopher G. Missen<br />
<br />
# Disabled 2011-04-27 - password-protected now and not valid<br />
#[http://yujinjeong.wordpress.com/category/GAM666/feed/]<br />
#name=YuJin Jeong<br />
<br />
[http://crgosselin.blogspot.com/feeds/posts/default]<br />
name=Chris Ryan Gosselin<br />
<br />
[http://slaw12.wordpress.com/feed/ ]<br />
name=Stephanie Law<br />
<br />
[http://ysliu2.blogspot.com/feeds/posts/default]<br />
name=Yansong Liu<br />
<br />
[http://www.drizhepolov.com/blog/?feed=rss2]<br />
name=Vladimir Drizhepolov<br />
<br />
[http://bhavanesh.wordpress.com/feed/]<br />
name=Bhavanesh Patel<br />
<br />
[http://xwu0102.blogspot.com/feeds/posts/default/-/oop344]<br />
name=Xiaojiang Wu<br />
<br />
[http://rhui4.wordpress.com/feed/ ]<br />
name=Richard Hui<br />
<br />
[http://invinciblyignorant.wordpress.com/category/OOP344/feed/]<br />
name=Jason Burton<br />
<br />
[http://goldenration.wordpress.com/feed/]<br />
name=HongGeun Park<br />
<br />
[http://thupten.veryusefulinfo.com/?feed=rss2]<br />
name=Thupten Choephel<br />
<br />
[http://priyadeep.wordpress.com/feed/]<br />
name=Priyadeep Gill<br />
<br />
[http://kyle205website.info/wordpress/?feed=rss2]<br />
name=Khai Huynh<br />
<br />
[http://dkxy.net/blog/tag/oop344/feed/]<br />
name=Dale Karp<br />
<br />
[http://vbluzmans.wordpress.com/feed/]<br />
name=Vitaly Bluzmans<br />
<br />
[http://akkimblog.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Kerry Taylor<br />
<br />
<br />
[http://alf1488.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Yegor Tyunin<br />
<br />
[http://sbr600.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Matthew Ortofsky<br />
<br />
[http://pbrown9.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Paul Brown<br />
<br />
[http://jzaidi.wordpress.com/feed/]<br />
name=Jawwad Zaidi<br />
<br />
[https://rainulf.ca/rss.php?tags=cdot]<br />
name=Jose Rainulf Pineda<br />
<br />
[http://donchel.wordpress.com/feed/]<br />
name=Dong Cheol Cha<br />
<br />
[http://sweerdenburg.wordpress.com/category/seneca/feed/]<br />
name=Steven Weerdenburg<br />
<br />
[http://jyang42.blogspot.com/feeds/posts/default]<br />
name=Jing Yang<br />
<br />
[http://tarinc.wordpress.com/feed/]<br />
name=Tarin Choudhury<br />
<br />
[http://jtdonaldson21.blogspot.com/feeds/posts/default]<br />
name=Jeshu Donaldson<br />
<br />
[http://bccp32.blogspot.com/feeds/posts/default]<br />
name=Yauheni Khabian<br />
<br />
[http://mark-os.blogspot.com/feeds/posts/default]<br />
name=Mark Eamiguel<br />
<br />
[http://kweber1.blogspot.com/feeds/posts/default]<br />
name=Kyle Weber<br />
<br />
[http://mustafaredha.wordpress.com/category/planet-cdot/feed]<br />
name=Mustafa Redha<br />
<br />
[http://andrewasdesigned.blogspot.com/feeds/posts/default/-/SBR600]<br />
name=Andrew Singh<br />
<br />
[http://escom0.blogspot.com/feeds/posts/default]<br />
name=Eric Shum<br />
<br />
# Disabled 2011-04-27 - blog was deleted<br />
#[http://open-ht.blogspot.com/feeds/posts/default]<br />
#name=Hoc Tran<br />
<br />
[http://dvkitancheva.wordpress.com/feed/]<br />
name=Denitsa Kitancheva<br />
<br />
[http://vanjason.wordpress.com/category/sbr600/feed]<br />
name=Jason Van<br />
<br />
[http://kpangilinan.wordpress.com/feed]<br />
name=Kenneth Pangilinan<br />
<br />
[http://ajcondinho.blogspot.com/feeds/posts/default/-/opensource]<br />
name=Andrew Condinho<br />
<br />
[http://blog.esmnetworks.com/category/planet-cdot/feed]<br />
name=Adrian Pruteanu<br />
<br />
[http://stevebologna.wordpress.com/category/Open-Source/feed/]<br />
name=Stephen Bologna<br />
<br />
[http://www.winterleaf.ca/blog/category/oop344/feed/]<br />
name=Daniel Slessarev<br />
<br />
[http://ycshon.blogspot.com/feeds/posts/default]<br />
name=Young Chol Shon<br />
<br />
[http://jwpark2.blogspot.com/feeds/posts/default]<br />
name=Jaewoo Park<br />
<br />
[http://klasconia.wordpress.com/feed/]<br />
name=Kevin Lasconia<br />
<br />
[http://kmcdonald11.blogspot.com/feeds/posts/default]<br />
name=Kaitlyn McDonald<br />
<br />
[http://jrobinson7.wordpress.com/feed/]<br />
name=James Robinson<br />
<br />
[http://trusu.blogspot.com/feeds/posts/default]<br />
name=Traian Rusu<br />
<br />
[http://blockrockinpete.blogspot.com/feeds/posts/default/-/OSD600]<br />
name=Pete Leaning<br />
<br />
[http://tyler-taehee-lee.blogspot.com/feeds/posts/default/-/SBR600]<br />
name=Tae Hee Lee<br />
<br />
[http://www.kaitlyncallow.com/Blog/?feed=rss2&cat=86]<br />
name=Kaitlyn Callow<br />
face=http://www.kaitlyncallow.com/Dump/kait_avatar.jpg<br />
<br />
[http://saad-husain.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Saad Husain<br />
<br />
[http://jevangelos.wordpress.com/feed/]<br />
name=James Evangelista<br />
<br />
# Disabled 2011-04-27 - not a feed link<br />
#[http://sajed481.wordpress.com/SBR600/]<br />
#name=M.A Sajed Shadani<br />
<br />
[http://rizwanhaq.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Rizwan Haq<br />
<br />
[http://tuori.tk/blog/blogs/blog1.php?tempskin=_rss2&cat=15]<br />
name=Matthew Tuori<br />
<br />
[http://ktaraghi.blogspot.com/feeds/posts/default]<br />
name=Khosro Taraghi<br />
<br />
[http://opensourceftw.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Anthony Boccia<br />
<br />
[http://perfectlylogical.wordpress.com/category/sbr600/feed/]<br />
name=Stephen Hall<br />
<br />
[http://rocellaj.wordpress.com/feed/]<br />
name=Rocella Jimenez<br />
<br />
[http://justinpaulmorgan.blogspot.com/feeds/posts/default]<br />
name=Justin Morgan<br />
<br />
[http://gcasella.blogspot.com/feeds/posts/default]<br />
name=Gian-Luca Casella<br />
<br />
[http://pratikamin.wordpress.com/category/sbr600/feed/]<br />
name=Pratik Amin<br />
<br />
[http://syang00.wordpress.com/feed/]<br />
name=Stephanie Yang<br />
<br />
[http://tewestacott.wordpress.com/category/SBR600/feed/]<br />
name=Todd Westacott<br />
<br />
[http://aparda.wordpress.com/category/SBR600//feed/]<br />
name=Andrew Parda<br />
<br />
[http://gjuhasz1.wordpress.com/feed/]<br />
name=Gergely Juhasz<br />
<br />
[http://completefail.wordpress.com/category/SBR600/feed/]<br />
name=Joshua Y. Koh<br />
<br />
[http://myuberwebsite.blogspot.com/feeds/posts/default]<br />
name=Dmitry Artemenko<br />
<br />
[http://cgomes7.wordpress.com/feed/]<br />
name=Cesar Gomes<br />
<br />
[http://supbroseph.wordpress.com/feed/]<br />
name=Houssam haidar<br />
<br />
[http://www.bradchen.com/rss/blog/open%20source]<br />
name=Brad Chen (vvasabi)<br />
<br />
[http://asabir.wordpress.com/feed/]<br />
name=Adeel Sabir (asabir)<br />
<br />
[http://libresparks.wordpress.com/category/SBR600/feed/]<br />
name=Alfred Liu<br />
<br />
[http://acook6.blogspot.com/feeds/posts/default/-/open-source]<br />
name=Alan Cook<br />
<br />
[http://coding.shaunofthelive.com/feeds/posts/default/-/oop344]<br />
name=Shaun Hill<br />
<br />
[http://maoli1207.blogspot.com/feeds/posts/default/-/open-source]<br />
name=Mao Hua Li<br />
<br />
[http://fossjon.wordpress.com/feed/]<br />
name=Jon Chiappetta<br />
<br />
[http://dperit.blogspot.com/feeds/posts/default/-/cdot]<br />
name=David Perit<br />
<br />
[http://szafar8.wordpress.com/tag/cdot/feed/]<br />
name=Salman Zafar<br />
<br />
[http://mbuttu.wordpress.com/category/Open-Source/feed/]<br />
name=Mohammed Buttu<br />
<br />
[http://brianlimtemp.blogspot.com/feeds/posts/default/-/CDOT]<br />
name=Brian Lim<br />
</pre></div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Planet_CDOT_Feed_List&diff=65192Planet CDOT Feed List2011-06-07T17:51:10Z<p>Ladanzahir: </p>
<hr />
<div>= Introduction =<br />
<br />
Seneca students and faculty working on open source related projects and research, as well as some faculty, students, and researchers from other institutions, use [http://zenit.senecac.on.ca/~chris.tyler/planet/ Planet CDOT] to aggregate their blogs. This page contains the information about who is blogging in [http://www.planetplanet.org/ Planet Feed Reader format] and serves as the feed configuration for the planet.<br />
<br />
If you do not have an existing blog, you can open a free account at [http://wordpress.com/ Wordpress.com] or [https://www.blogger.com/ Blogger.com] or you can set up your own blog software such as [http://www.s9y.org Serendipity].<br />
<br />
'''Note:''' Additions to the feed list will not take effect until they are merged into the Planet configuration, which is an automatic process scheduled at regular intervals. If you add a feed and do not see it picked up in the Planet within three hours, please check your feed entry carefully and then contact [[User:Chris Tyler|Chris Tyler]] .<br />
<br />
= Requirements =<br />
<br />
* Blog postings fed to the planet must conform to the [[Blog Guidelines]].<br />
* Feeds that are inactive for a significant period of time may get deleted from this list.<br />
<br />
= Using a Tagged/Category Feed =<br />
<br />
A tagged or category feed includes only articles that are tagged with particular keywords or placed in a particular topic category. This can be useful for sending only selected posts to the planet.<br />
<br />
These are the URL formats for tagged or category feeds on popular blogging services/software:<br />
<br />
* [http://www.wordpress.com Wordpress]: <code><nowiki>[http://</nowiki>''blog-user-name''.wordpress.com/category/''category-name''/feed/]</code><br />
* [http://blogger.com Blogger]: <code><nowiki>[http://</nowiki>''blog-user-name''.blogspot.com/feeds/posts/default/-/''category-name'']</code><br />
* [http://s9y.org Serendipity]: <code><nowiki>[http://</nowiki>''blog-main-url''/index.php?/feeds/categories/''cateogrynumber''-''categoryname'']</code><br />
<br />
= Feed Info Format =<br />
<br />
You can add your blog's [http://en.wikipedia.org/wiki/RSS_(file_format) RSS feed] at the end of the list below by specifying the following:<br />
<br />
# The URL to your blog's open source Atom or [http://en.wikipedia.org/wiki/RSS_(file_format) RSS Feed] (i.e., a category or tag). NOTE: Please do not put the URL to your blog -- use the URL for your feed. Please do not use the feed for your entire blog (unless your blog contains only open source-related postings). We only want open source related content.<br />
# Your name as you want it to appear in the list of names for the planet<br />
# Optionally, a URL to a [http://en.wikipedia.org/wiki/Hackergotchi hackergotchi] ([http://wouterverhelst.livejournal.com/21322.html how to]). Your picture should be an 65x85 PNG with a transparent background.<br />
<br />
<br />
= Feeds =<br />
<br />
<pre><br />
<br />
[http://ladanzahir.wordpress.com/category/CDOT/feed/]<br />
name=Ladan Zahiroleslam Zade<br />
<br />
<br />
[http://mschranz.wordpress.com/category/seneca_college/feed/]<br />
name=Matthew Schranz<br />
<br />
[http://www.spectakular.com/category/open-source/feed/]<br />
name=Simon Jung<br />
<br />
[http://jbuckley.ca/category/open-source/feed/]<br />
name=Jon Buckley<br />
<br />
[http://mbrzuzy.wordpress.com/category/open-source/feed/]<br />
name=Marcin Brzuzy<br />
<br />
[http://ben1amin.wordpress.com/category/seneca/feed/]<br />
name=Benjamin Chalovich<br />
<br />
[http://edghardest1.wordpress.com/category/open-source-topics/feed/]<br />
name=Ed Arvelaez<br />
<br />
[http://www.ashkansotoudeh.com/blog/?tag=oop344&feed=rss2]<br />
name=Ashkan Sotoudeh<br />
<br />
[http://dboddie46.wordpress.com/category/SBR600A/feed/]<br />
name=Derrick Boddie<br />
<br />
[http://aali83.blogspot.com/feeds/posts/default/-/oop344]<br />
name=Ahmad Ali<br />
<br />
[http://gr8can8dian.wordpress.com/category/sbr600/feed/]<br />
name=Lorin Soura<br />
<br />
[http://kirtonmike.wordpress.com/category/SBR600/feed/]<br />
name=Mike Kirton<br />
<br />
[http://fuzzux.wordpress.com/category/SBR600/feed/]<br />
name=Tim Furzer<br />
<br />
[http://nageyi.wordpress.com/feed/]<br />
name=Faisal Nageyi<br />
<br />
[http://KrazyDre.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Andrei Artamonov<br />
<br />
[http://mjcorsame.wordpress.com/feed/]<br />
name=Michael John Corsame<br />
<br />
[http://msbreezy12.wordpress.com/category/SBR/feed/]<br />
name=Chantell Mcintosh<br />
<br />
# Disabled 2011-04-28 - empty blog<br />
#[http://mrtait1.blogspot.com/feeds/posts/default/-/oop344]<br />
#name=Matthew Tait<br />
<br />
[http://brettvangennip.wordpress.com/category/sbr600/feed]<br />
name=Brett van Gennip<br />
<br />
[http://sbr600cabbott.blogspot.com/feeds/posts/default]<br />
name=Chris Abbott<br />
<br />
[http://kopay.wordpress.com/category/sbr600-win2011/feed]<br />
name=Pirathapan Sivalingam<br />
<br />
[http://mysnogorodsky.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Marina Ysnogorodsky<br />
<br />
[http://asa.veryusefulinfo.com/?feed=rss2]<br />
name=Ali Samimi<br />
<br />
# Disabled 2011-04-28 - empty blog<br />
#[http://coreyangus.blogspot.com/feeds/posts/default/-/oop344]<br />
#name = Corey Angus<br />
<br />
[http://wsong18.blogspot.com/feeds/posts/default/-/OOP344]<br />
name = Wei Song<br />
<br />
# Disabled 2011-04-28 - blog deleted<br />
#[http://kijeongkim.blogspot.com/feeds/posts/default]<br />
#name=Kijeong Kim<br />
<br />
[http://davidsosd60020102blog.blogspot.com/feeds/posts/default]<br />
name=David Takasaki<br />
<br />
[http://zwang98.blogspot.com/feeds/posts/default]<br />
name=Joe Wang<br />
<br />
[http://sbr700.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Jonathan Deni<br />
#face=https://techontherun.sslpowered.com/techontherun.ca/jonthumb.png<br />
<br />
[http://dgilloch.blogspot.com/feeds/posts/default]<br />
name=Daniel Gilloch<br />
<br />
[http://jmchen11.wordpress.com/feed/]<br />
name=Jianming Chen<br />
<br />
[http://paulfedora.wordpress.com/tag/cdot/feed/]<br />
name=Paul Whalen<br />
<br />
[http://dmchisho.wordpress.com/feed/]<br />
name=David Chisholm<br />
<br />
[http://pokerface3.blogspot.com/feeds/posts/default/-/SBR?alt=rss]<br />
name=David Cabral<br />
<br />
[http://zbhuang1.blogspot.com/feeds/posts/default/-/open%20source]<br />
name=Zhibin Huang<br />
<br />
[http://sidsbr.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Sadiki Latty<br />
<br />
[http://orel60.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Or-el Mousaffi<br />
<br />
[http://aryafarzan.wordpress.com/category/OOP344/feed/]<br />
name=Arya Farzan<br />
<br />
[http://dsventura.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Dan Ventura<br />
<br />
[http://cadecairos.blogspot.com/feeds/posts/default/-/open-source]<br />
name=Christopher DeCairos<br />
<br />
[http://acfunktron.blogspot.com/feeds/posts/default]<br />
name=Anton Chan<br />
<br />
[http://adaniel3.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Arlene Daniel<br />
<br />
[http://tyrant911-processingdotjs.blogspot.com/feeds/posts/default/-/processing.js]<br />
name=Alex Londono<br />
<br />
# Disabled 2009-11-13 by Chris Tyler <chris.tyler@senecac.on.ca> (ctyler on IRC)<br />
# Ausley: Contact me to discuss before re-enabling.<br />
#[http://ausleyj.blogspot.com/feeds/posts/default]<br />
#name=Ausley Johnson<br />
<br />
[http://arminoop344.blogspot.com/feeds/posts/default]<br />
name=Armin Kumarshellah<br />
<br />
[http://cloudscorpion.blogspot.com/feeds/posts/default/-/OOP344]<br />
name=Joseph Hughes<br />
<br />
[http://travisrawn.blogspot.com/feeds/posts/default]<br />
name=Travis Rawn<br />
<br />
[http://jmpiltz.blogspot.com/feeds/posts/default]<br />
name=Jonathan Piltz<br />
<br />
[http://andrewgrimo.wordpress.com/category/open-source/feed/]<br />
name=Andrew Grimo<br />
<br />
[http://apvsbr700.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Alex Vlahopoulos<br />
#face=https://techontherun.sslpowered.com/techontherun.ca/alexthumb.png<br />
<br />
[http://asalga.wordpress.com/category/open-source/feed/]<br />
name=Andor Salga (asalga)<br />
<br />
[http://jabhad.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Mohamed Aden<br />
<br />
[http://jonathandeni.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Jonathan Deni<br />
#face=https://techontherun.sslpowered.com/techontherun.ca/jonthumb.png<br />
<br />
[http://manoutoftime.wordpress.com/category/open-source/feed/]<br />
name=Konstantin Novichikhin<br />
<br />
[http://scorchedicee.wordpress.com/category/Seneca/feed/]<br />
name=Adam Sone<br />
<br />
[http://murraysaul.wordpress.com/feed/]<br />
name=Murray Saul<br />
<br />
[http://xwn740arcadeproject.blogspot.com/feeds/posts/default]<br />
name=Arcade Project - LUX Group@<br />
#face=http://matrix.senecac.on.ca/~mpaivaneto/ourbaby.png<br />
<br />
[http://crashopensource.blogspot.com/feeds/posts/default/-/open-source]<br />
name=Lukas Blakk (lsblakk)<br />
#face=http://avnerd.tv/sharedFiles/lukas_hackergotchi.png<br />
<br />
[http://nashutzu.blogspot.com/feeds/posts/default]<br />
name=George Popescu (GeorgeP)<br />
<br />
[http://blog.chris.tylers.info/index.php?/feeds/categories/20-Seneca-Planet.rss]<br />
name=Chris Tyler (ctyler)<br />
face=http://zenit.senecac.on.ca/~chris.tyler/chris_tyler_hackergotchi_4a.png<br />
<br />
[http://vocamus.net/dave/?feed=rss2&category_name=Seneca]<br />
name=David Humphrey<br />
<br />
[http://gratnam1.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Gajendran Ratnam (gratnam1)<br />
<br />
[http://senecajon.blogspot.com/feeds/posts/default]<br />
name=Jonathan Cheung (jcheung23)<br />
<br />
# Disabled 2011-04-28 - blog was removed<br />
#[http://blog.markparuzel.com/feed/]<br />
#name=Mark Paruzel<br />
<br />
[http://mmszuto.blogspot.com/feeds/posts/default]<br />
name=Michael Szutu<br />
<br />
[http://lsdaly.blogspot.com/feeds/posts/default]<br />
name=Louis Daly (lsdaly)<br />
<br />
# Disabled 2009-01-25 due to 404's (domain expired)<br />
#[http://www.foobartastic.com/feed/]<br />
#name=Tom Aratyn<br />
<br />
[http://bhearsum.blogspot.com/feeds/posts/default/-/seneca]<br />
name=Ben Hearsum<br />
<br />
# Following feed is invitation-only. Disabled 2010-09-23 CTyler<br />
#[http://www.jyzyy.blogspot.com/feeds/posts/default/-/opensource]<br />
#name=Jyoti<br />
<br />
# Re-enabled 2011-04-29 - new blog URL<br />
# Disabled 2009-09-15 due to 404's (site rearranged?)<br />
[http://tea.cesaroliveira.net/archives/tag/seneca/feed]<br />
name=Cesar Oliveira<br />
<br />
[http://r3ap3r.wordpress.com/category/seneca/feed]<br />
name=Brandon Collins<br />
<br />
# Disabled 2011-04-28 - blog was deleted<br />
#[http://jrgoncal.blogspot.com/feeds/posts/default]<br />
#name=Justin Goncalves (jrgoncal)<br />
#face=http://img517.imageshack.us/img517/9865/bearzp5.jpg<br />
<br />
# Disabled 2011-04-28 - blog is now private<br />
#[http://tlo5.blogspot.com/feeds/posts/default]<br />
#name=Tommy Lo (tlo5)<br />
<br />
[http://armenzg.blogspot.com/feeds/posts/default/-/open%20source]<br />
name=Armen Zambrano G. (armenzg)<br />
<br />
[http://mikemoz.blogspot.com/feeds/posts/default/-/Open%20Source]<br />
name=Michael Mullin<br />
<br />
[http://mikemoz.blogspot.com/feeds/posts/default/-/Mozilla_GFX]<br />
name=Michael Mullin<br />
<br />
# Returned 410 on 2008-09-13 - disabled CTyler<br />
#[http://rueenfiez.wordpress.com/category/open-source/feed/]<br />
#name=Rueen Fiez<br />
<br />
# Returning 404 on 2008-09-13 - disabled CTyler<br />
#[http://jsafavi.wordpress.com/category/open-source/feed/]<br />
#name=Jason Safavi<br />
<br />
[http://vlam6.wordpress.com/category/open-source/feed/]<br />
name=Vincent Lam<br />
<br />
[http://dejant.blogspot.com/feeds/posts/default]<br />
name=Dejan Tolj<br />
<br />
[http://shivaris.blogspot.com/feeds/posts/default/-/OSD600]<br />
name=Hien Huynh<br />
<br />
[http://raynrant.blogspot.com/feeds/posts/default]<br />
name=Andrew Raynier (JM)<br />
face=http://zenit.senecac.on.ca/wiki/imgs/Hackergotchi.png<br />
<br />
[http://vijeysdps909.blogspot.com/feeds/posts/default]<br />
name=Vijey Bala<br />
<br />
[http://sedejong.blogspot.com/feeds/posts/default]<br />
name=Shomar Dejonge<br />
<br />
[http://dbaranski.wordpress.com/category/open-source/feed/]<br />
name=Dominic Baranski<br />
<br />
#[http://crashopensource.wordpress.com/category/open-source/feed/]<br />
#name=Lukas Blakk<br />
<br />
[http://kmsingh.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Kerry M. Singh<br />
<br />
[http://tjduavis.wordpress.com/category/open-source/feed/]<br />
name=Timothy Duavis<br />
<br />
# Disabled 2011-04-28 - entire website is missing<br />
#[http://ashughes.com/?q=taxonomy/term/2/0/feed]<br />
#name=Anthony Hughes<br />
<br />
[http://opensourcekennethlee.blogspot.com/feeds/posts/default]<br />
name=Kenneth Lee<br />
<br />
[http://cleung.wordpress.com/category/Seneca/feed/]<br />
name=Catherine Leung<br />
<br />
[http://dtheosab.wordpress.com/category/open-source/feed/]<br />
name=Daino Theosabrata<br />
<br />
# This is my old blog<br />
[http://simon-jung.blogspot.com/feeds/posts/default]<br />
name=Simon Jung (old)<br />
<br />
[http://aeraj.blogspot.com/feeds/posts/default/-/open%20source]<br />
name=AJ Rehman<br />
<br />
[http://xrayon.blogspot.com/feeds/posts/default]<br />
name=Fima Kachinski<br />
<br />
[http://littlesvr.ca/grumble/category/safeforseneca/feed/]<br />
name=Andrew Smith<br />
<br />
[http://littlesvr.ca/masters/feed]<br />
name=Andrew Smith (master's)<br />
<br />
[http://jbopensrc.wordpress.com/category/open-source/feed]<br />
name=Jesse Buchanan<br />
<br />
[http://ayhfung.blogspot.com/feeds/posts/default]<br />
name=Andrew Fung<br />
<br />
# Returned 404 on 2008-09-13 - disabled CTyler<br />
#[http://sloose.wordpress.com/category/open-source/feed/]<br />
#name=Peter Ljubanovic<br />
<br />
[http://mozcoz.blogspot.com/feeds/posts/default/-/Open%20Source]<br />
name=Amit Gundu<br />
<br />
# Changed CTyler 2009-02-12 from [http://www.blogger.com/feeds/15922666655846514311/blogs]<br />
[http://dsmukherji.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Devashish<br />
<br />
[http://yhan11.wordpress.com/category/open-source/feed]<br />
name=Yongsheng Han<br />
<br />
[http://peter.sykokillers.com/category/open-source/feed/]<br />
name=Peter Chan<br />
<br />
[http://www.c3dl.org/index.php/category/c3dl-dev/feed]<br />
name=Seneca Canvas3D Team<br />
<br />
# Updated 2011-04-28 - corrected feed URL<br />
[http://peterevanoff.wordpress.com/category/open-source/feed/]<br />
name=Peter Evanoff<br />
<br />
# Disabled 2011-04-28 - flagged as a malware-loaded site by Google<br />
<br />
#[http://radoye.net1zen.com/wp-rss2.php?cat=3]<br />
#name=Radovan Nesic<br />
<br />
[http://blog.cresencia.ca/category/open-source/osd600/feed/]<br />
name=Joseph Cresencia<br />
<br />
[http://bertenshaw.blogspot.com/feeds/posts/default]<br />
name=David Bertenshaw<br />
<br />
[http://ljubomirgorscak.blogspot.com/feeds/posts/default]<br />
name=Ljubomir Gorscak<br />
<br />
[http://sameropensource.blogspot.com/feeds/posts/default]<br />
name=Samer Ziadeh (samer)<br />
<br />
# Following feed not working and temporarily disabled<br />
# 2010-09-23 by CTyler<br />
#[http://jamesboston.ca/cms/taxonomy/term/1/0/feed]<br />
#name=James Boston<br />
#face=http://jamesboston.ca/hackergotchi.png<br />
<br />
[http://dailypackage.fedorabook.com/index.php?/feeds/index.rss2]<br />
name=Fedora Daily Package<br />
<br />
[http://oooblog.fardad.com/feeds/posts/default/-/Seneca]<br />
name=Fardad Soleimanloo<br />
<br />
[http://seneblog.fardad.com/feeds/posts/default]<br />
name=Fardad Soleimanloo<br />
<br />
[http://selmys.wordpress.com/category/opensource/feed]<br />
name=John Selmys<br />
face=http://cs.senecac.on.ca/~selmys/john_selmys_hackergotchi.png<br />
<br />
[http://pconstantino.wordpress.com/feed]<br />
name=Patricia Constantino<br />
<br />
[http://bombshelter13.blogspot.com/feeds/posts/default]<br />
name=Gregory Masseau<br />
#face=http://matrix.senecac.on.ca/~gjmasseau/userpic.jpg<br />
<br />
[http://zadkielm.blogspot.com/feeds/posts/default/-/open%20source]<br />
name=Ezadkiel Marbella<br />
<br />
[http://blog.sidkalra.com/category/opensource/feed]<br />
name=Sid Kalra<br />
<br />
[http://pplam3.blogspot.com/feeds/posts/default]<br />
name=Patrick Lam<br />
<br />
# Disabled 2011-04-28 - blog is now private<br />
#[http://twlai1.blogspot.com/feeds/posts/default]<br />
#name=Tony Lai<br />
<br />
[http://dee132.blogspot.com/feeds/posts/default/-/seneca]<br />
name=Chris Bishop<br />
<br />
# Updated 2011-04-28 - updated feed URL<br />
[http://zghansar.wordpress.com/category/open-source/feed/]<br />
name=Zaid Ghansar<br />
face=http://www.alhudainstitute.ca/zaid/z.png<br />
<br />
[http://aaronmt.com/?feed=rss2]<br />
name=Aaron Train<br />
face=http://matrix.senecac.on.ca/~amtrain/other/mypic.png<br />
<br />
[http://scottosd.blogspot.com/feeds/posts/default/-/Open%20Source/]<br />
name=Scott Lunel<br />
<br />
# Updated 2009-04-16, new blog. - scarter4<br />
# Disabled 2009-11-27 due to wrong feed URL<br />
#[http://scarter4.wordpress.com/category/seneca/]<br />
#name=Stephen Carter<br />
<br />
# Disabled 2009-01-23 CTyler due to 404s<br />
#[http://shdinis.blogspot.com/feeds/posts/default]<br />
#name=Shawn Dinis<br />
<br />
[http://belligero.org/index.php?option=com_content&view=section&id=1&format=feed&type=rss]<br />
name=Jason Tarka<br />
<br />
# Updated 2011-04-28 - no more tag, but still Seneca related<br />
[http://petermcintyre.wordpress.com/feed/]<br />
name=Peter McIntyre<br />
<br />
[http://vesperrin.blogspot.com/feeds/posts/default/-/open%20source]<br />
name=Leonard Lee (vesper)<br />
<br />
[http://jsdoodnauth.wordpress.com/category/open-source/feed/]<br />
name=Joshua Doodnauth<br />
<br />
[http://johnhford.blogspot.com/feeds/posts/default/-/Open%20Source]<br />
name=John Ford (John64)<br />
<br />
[http://mohaksblog.blogspot.com/feeds/posts/default]<br />
name=Mohak Vyas<br />
#face=http://matrix.senecac.on.ca/~mdvyas/MohakVyas.png<br />
<br />
[http://pdirezze.blogspot.com/feeds/posts/default]<br />
name=Paul DiRezze<br />
<br />
# Following link no longer valid. Disabled 2010-09-23 CTyler<br />
#[http://www.ndaversa.com/category/open-source/feed]<br />
#name=Nino D'Aversa<br />
<br />
[http://miltonpaiva.wordpress.com/feed/]<br />
name=Milton Paiva<br />
#face=http://matrix.senecac.on.ca/~mpaivaneto/orkut.png<br />
<br />
[http://de-luxer.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Nestor Chan<br />
#face=http://matrix.senecac.on.ca/~tnchan/n516840997_9173.PNG<br />
<br />
[http://varinderjhand.wordpress.com/feed/]<br />
name=Varinder Singh <br />
<br />
[http://ajhooper.blogspot.com/feeds/posts/default]<br />
name=Aaron Hooper<br />
<br />
[http://nadavid.blogspot.com/feeds/posts/default]<br />
name=Neil David<br />
<br />
[http://cdpatel1.blogspot.com/feeds/posts/default]<br />
name=Chinmay Patel<br />
#face=http://www.geocities.com/chinmay_patel@ymail.com/chinmay.jpg<br />
<br />
[http://jvalianes.blogspot.com/feeds/posts/default]<br />
name=Jesse Valianes<br />
<br />
[http://bbarcick.blogspot.com/feeds/posts/default/-/Open%20Source]<br />
name=Bartosz Barcicki<br />
<br />
[http://heidenreich.wordpress.com/tag/seneca-college/feed/]<br />
name=Michal Heidenreich<br />
<br />
[http://kezhong.wordpress.com/feed/atom/]<br />
name=Kezhong Liang <br />
<br />
[http://wfred.wordpress.com/category/open-source/feed/]<br />
name=Fred Wang<br />
<br />
[http://jsinghfoss.wordpress.com/category/spring-framework/feed/]<br />
name=Jatinder Singh<br />
<br />
[http://rparsi.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Rahi Parsi<br />
<br />
# Changed 2011-04-28 - missing a capital "S" from Seneca to display feed<br />
[http://aaronrey15.blogspot.com/feeds/posts/default/-/Seneca]<br />
name=Aaron Chan<br />
<br />
# Disabled 2011-04-28 - posts were deleted, empty feed<br />
#[http://flashalive.wordpress.com/category/Open%20Source/feed/]<br />
#name=Ryan Wang<br />
<br />
[http://kvuhome.blogspot.com/feeds/posts/default/-/Open%20Source]<br />
name=Khanh Vu<br />
<br />
[http://daeseonmoon.wordpress.com/category/open-source/feed/]<br />
name=Daeseon Moon<br />
<br />
[http://lzahir.blogspot.com/feeds/posts/default/-/Open%20Source]<br />
name=Ladan Zahiroleslam Zadeh<br />
<br />
[http://abraini.wordpress.com/category/seneca/feed/]<br />
name=Andrew Braini<br />
<br />
[http://minicheong.blogspot.com/feeds/posts/default]<br />
name=Frankie Law<br />
<br />
# Following feed changed from http://www.heyqule.net/blog/tech/oss/feed<br />
# on 2010-09-23 by CTyler.<br />
[http://www.heyqule.net/taxonomy/term/44/0/feed]<br />
name=Allen JF Xie (heyqule)<br />
<br />
[http://farhadnorouzi.blogspot.com/feeds/posts/default]<br />
name=Farhad Norouzi<br />
<br />
[http://jdeport.wordpress.com/category/software-development/open-source/feed/]<br />
name=John Dang<br />
<br />
[http://pliu.wordpress.com/category/open-source/feed/]<br />
name=Peter Liu<br />
<br />
# Feed not working - temporarily disabled 2010-09-23 CTyler<br />
#[http://www.jerrypau.ca/?feed=rss2&cat=3]<br />
#name=Jerry Pau<br />
#face=http://www.jerrypau.ca/blog-face-1.png<br />
<br />
[http://blog.wikiscraps.com/feeds/posts/default/-/oss]<br />
name=M. Mead Armsby (mead)<br />
<br />
[http://paritosha.blogspot.com/feeds/posts/default]<br />
name=Paritosh Aggarwal(paritosh1010)<br />
<br />
# Private blog. Disabled 2010-09-23 CTyler.<br />
#[http://myblog110.wordpress.com/category/open-source/feed]<br />
#name=Tahereh<br />
<br />
# Disabled 2011-04-28 - empty feed, all posts were removed<br />
#[http://challenger110.wordpress.com/category/software-development/open-source/censored/feed/]<br />
#name=Davoud Salahi Rad<br />
<br />
[http://wb-os.blogspot.com/feeds/posts/default]<br />
name=Le Yang<br />
<br />
[http://garykwong.wordpress.com/category/education/feed/]<br />
name=Gary Kwong (nth10sd)<br />
<br />
[http://yuenhoe.co.cc/blog/category/mozilla/feed/]<br />
name=Lim Yuen Hoe (moofang)<br />
<br />
# Disabled 2011-04-27 - empty feed, needs to be udpated<br />
#[http://tonychestnut.wordpress.com/category/mozilla/ubiquity/feed/]<br />
#name=Vu Dinh The (tonyvu)<br />
<br />
[http://opensourceproject.wordpress.com/category/open-source/feed/]<br />
name=Nabeel Khan (nkhan26)<br />
<br />
# Disabled 2011-04-27 - suspended domain<br />
#[http://solfu.net/tech/category/personas-for-thunderbird/feed/]<br />
#name=Yaoquan (seith)<br />
<br />
[http://xiajunshi.wordpress.com/category/open-source/feed/]<br />
name=Shelley Shi<br />
<br />
[http://hendrikinmozilla.wordpress.com/feed/]<br />
name=Hendrik<br />
<br />
[http://t3rrychan.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Terry Chen (jchen124)<br />
<br />
[http://blog.bchao.ca/feeds/posts/default?alt=rss]<br />
name=Boris Chao<br />
<br />
[http://ahiltssbr700.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Adam Hilts<br />
<br />
[http://ysasaki600.wordpress.com/feed/]<br />
name=Yu Sasaki<br />
<br />
[http://enderstruth.wordpress.com/category/open-source/feed/]<br />
name=Roger Dicke<br />
<br />
[http://wobblyretroaction.blogspot.com/feeds/posts/default/-/Open%20source]<br />
name=Matthew Lam<br />
<br />
[http://asydik.wordpress.com/category/professional/open-source/feed/]<br />
name=Mickael Medel (aSydiK)<br />
<br />
[http://cwd89.blogspot.com/feeds/posts/default/-/project]<br />
name=Carl Desautels<br />
<br />
[http://rselby-oop344.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Remington Selby<br />
<br />
[http://mikey-osd600a.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Michael Dennis<br />
<br />
# Disabled 2011-04-27 - empty blog<br />
#[http://tjprogramming.blogspot.com/feeds/posts/default/-/seneca]<br />
#name=Timothy Catibog<br />
<br />
[http://horndavid.blogspot.com/feeds/posts/default?alt=rss]<br />
name=David Horn<br />
<br />
[http://annasob.wordpress.com/feed/]<br />
name=Anna Sobiepanek<br />
<br />
[http://drozhkov.blogspot.com/feeds/posts/default/-/seneca]<br />
name=Dmitriy Rozhkov<br />
<br />
[http://www.hodgin.ca/?feed=rss2&cat=4]<br />
name=Daniel Hodgin<br />
<br />
[http://buddhatron.wordpress.com/category/OSD600/feed/]<br />
name=Buddhatron<br />
<br />
[http://xderick.blogspot.com/feeds/posts/default/-/OSD]<br />
name=Yong Hong<br />
<br />
# This next link does not lead to an RSS or Atom feed. Disabled 2009-10-25 by CTyler.<br />
#[http://hoonkoon.blogspot.com/2009/09/oop344.html]<br />
#name=Taehoon Kim<br />
<br />
[http://s2000c.blogspot.com/feeds/posts/default/-/OOP344]<br />
name=Sunny Chau<br />
<br />
# This next link does not lead to an RSS or Atom feed. Disabled 2009-10-25 by CTyler.<br />
#[http://s2000c.blogspot.com/2009/09/oop344c.html]<br />
#name=Sunny Chau<br />
<br />
[http://kxu9.blogspot.com/feeds/posts/default]<br />
name=Kai Xu<br />
<br />
[http://oop-era.blogspot.com/feeds/posts/default]<br />
name=Eric Austerberry<br />
<br />
[http://docsage.blogspot.com/feeds/posts/default/-/OOP344]<br />
name=Eric Dell<br />
<br />
[http://ehren.wordpress.com/category/Seneca/feed/]<br />
name=Ehren Metcalfe<br />
<br />
[http://bsmith19.wordpress.com/category/Seneca/feed/]<br />
name=Brandon Smith<br />
<br />
[http://dcucereavii.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Diana Cucereavii<br />
<br />
# Disabled 2011-04-27 - site unreachable<br />
#[http://www.savantosis.com/?feed=rss2&cat=3]<br />
#name=Justin Robertson<br />
<br />
[http://paul-oop344.blogspot.com/feeds/posts/default/]<br />
name=Paul Repasi<br />
<br />
[http://istessema.wordpress.com/category/oop344/feed/]<br />
name=Iyosias Tessema<br />
<br />
[http://nedape.blogspot.com/feeds/posts/default]<br />
name=Neda Pezeshki<br />
<br />
[http://justletmepassoop344.blogspot.com/feeds/posts/default]<br />
name=Brian Parreno<br />
<br />
[http://dliu53.wordpress.com/category/open-source/feed/]<br />
name=Donghui Liu<br />
<br />
# Disabled 2011-04-27 - site not found<br />
#[http://oopblog.tdotshack.net/feeds/posts/default/-/OOP344]<br />
#name=Ryan Alexander<br />
<br />
[http://oop344ylseow.blogspot.com/feeds/posts/default]<br />
name=Yip Lim, Seow<br />
<br />
[http://mercedes-oop344.blogspot.com/feeds/posts/default]<br />
name=Suwon An<br />
<br />
[http://dtychshenko.blogspot.com/feeds/posts/default/-/OOP344]<br />
name=Dmitriy Tychshenko<br />
<br />
[http://victran.blogspot.com/feeds/posts/default/-/OOP344]<br />
name=Victor Tran<br />
<br />
# Changed 2011-04-27 - updated feed URL to proper<br />
[http://krazyazn.blogspot.com/feeds/posts/default]<br />
name=Michael Lin<br />
<br />
[http://xshi18.blogspot.com/feeds/posts/default]<br />
name=Xiaozhe Shi<br />
<br />
[http://feihong-xiong.blogspot.com/feeds/posts/default]<br />
name=Feihong Xiong<br />
<br />
[http://orbitalstation.wordpress.com/category/programming/feed/]<br />
name=Hasan Kamal<br />
face=http://matrix.senecac.on.ca/~hkamal-al-deen/images/Exclaim65x85.png<br />
<br />
[http://hduan2.wordpress.com/feed/]<br />
name= Haoliang Duan<br />
<br />
[http://anastasias-myblog.blogspot.com/feeds/posts/default/-/OOP344]<br />
name= Anastasia Semionova<br />
<br />
[http://franksun123.blogspot.com/feeds/posts/default/]<br />
name= Dong Sun<br />
<br />
[http://rkyoop344.blogspot.com/feeds/posts/default/]<br />
name=Keyan Ren<br />
<br />
[http://ctran13.blogspot.com/feeds/posts/default/-/oop344]<br />
name=Chi-Lea Tran<br />
<br />
[http://szymonsoop.blogspot.com/feeds/posts/default/]<br />
name= Szymon Ahmed<br />
<br />
[http://ywang268.blogspot.com/feeds/posts/default/]<br />
name=Yu Wang<br />
<br />
[http://wangcong422.blogspot.com/feeds/posts/default/]<br />
name=Cong Wang<br />
<br />
[http://dennyp.wordpress.com/category/Seneca/feed/]<br />
name=Denny Papagiannidis<br />
<br />
# Blog not found. Disabled 2010-09-23 CTyler.<br />
#[http://java-chinmay.blogspot.com/feeds/posts/default]<br />
#name= Chinmay Patel<br />
<br />
[http://sergedoescoding.blogspot.com/feeds/posts/default/]<br />
name= Sergiu Ecob<br />
<br />
# Disabled 2011-04-27 - blog deleted<br />
#[http://satijas.wordpress.com/category/OOP344/feed/]<br />
#name=Sasha Atijas<br />
<br />
# 404. Disabled 2010-09-23 CTyler.<br />
#[http://auzix.com/seneca/?feed=rss2]<br />
#name=Tyler Hackwood<br />
<br />
#[http://starbuck-blog.blogspot.com/feeds/posts/default]<br />
#name=Verity Li<br />
<br />
[http://gkrilov.blogspot.com/feeds/posts/default]<br />
name=Greg Krilov<br />
<br />
[http://qinzhi2001.blogspot.com/feeds/posts/default]<br />
name=David Chen<br />
<br />
[http://tchen-oop344.blogspot.com/feeds/posts/default]<br />
name=Terence Chen<br />
<br />
[http://opp344-yxue.blogspot.com/feeds/posts/default]<br />
name=Yong Xue<br />
# Disabled 2011-04-28 - had 2 other duplicate feeds<br />
# http://opp344-yxue.blogspot.com/feeds/posts/default/-/seneca<br />
# http://opp344-yxue.blogspot.com/feeds/posts/default/-/OOP344<br />
<br />
[http://ttsuji1.blogspot.com/feeds/posts/default]<br />
name=Trevor Tsuji<br />
<br />
[http://oyoung4.blogspot.com/feeds/posts/default]<br />
name=Oliver Young<br />
<br />
[http://minyxo.blogspot.com/feeds/posts/default/-/Open%20Source]<br />
name=Edward Sin<br />
<br />
# Blog not found - disabled 2010-09-23 CTyler<br />
#[http://oop344f09-niki.blogspot.com/feeds/posts/default]<br />
#name=Niki Simmalavong<br />
<br />
[http://jdbcdps.blogspot.com/feeds/posts/default]<br />
name=Julia Vasserman<br />
<br />
[http://shunyao-cpa.blogspot.com/feeds/posts/default]<br />
name=Shun Yao Zhang<br />
<br />
# Disabled 2009-11-27 due to 500's on feed link<br />
# Re-enabled 2011-04-27 - incorrect URL format fixed<br />
[http://oop344ylseow.blogspot.com/feeds/posts/default]<br />
name=Yip Lim Seow<br />
<br />
[http://capereir.wordpress.com/feed/]<br />
name=Chris Pereira<br />
<br />
[http://dev-blog.zerogin.com/category/opensource/feed/]<br />
name=Tom Wisniewski (t0mmyw)<br />
<br />
# Disabled 2011-04-27 - empty feed, rest of blog is not related<br />
#[http://majorbludd.wordpress.com/category/school/feed/]<br />
#name=Michael Dawson<br />
<br />
[http://cdnpadawan.wordpress.com/feed/]<br />
name=Matthew Daniels<br />
<br />
[http://processingjs.org/blog/?feed=rss2]<br />
name=Processing.js Blog<br />
<br />
[http://dseifried.wordpress.com/category/school/feed/]<br />
name=David Seifried<br />
<br />
[http://tandemwebdesign.ca/blog/?feed=rss2&cat=3]<br />
name=Matthew Adams<br />
<br />
[http://s-aleinikov.blog.ca/feed/atom/posts/]<br />
name=Sergey Aleinikov<br />
<br />
[http://wfchen2010.blogspot.com/feeds/posts/default]<br />
name=Wen Fang Chen<br />
<br />
[http://donna-oberes.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Donna Oberes<br />
<br />
[http://carolynwoodley.blogspot.com/feeds/posts/default]<br />
name=Carolyn Woodley<br />
<br />
[http://rocketpants.blog.ca/feed/rss2/posts/]<br />
name=Christopher Cheung<br />
<br />
[http://shengwei-seneca.blogspot.com/feeds/posts/default]<br />
name=Shengwei Wang<br />
<br />
[http://zakoop344.blogspot.com/feeds/posts/default]<br />
name=Wei Tong<br />
<br />
[http://gtawaf.blogspot.com/feeds/posts/default/-/Seneca]<br />
name=Gamal Tawaf <br />
<br />
[http://rift-tlosam.blogspot.com/feeds/posts/default/-/seneca]<br />
name=Brendan McDorman<br />
<br />
[http://hdc23.wordpress.com/category/OOP344/feed]<br />
name=Dachuan Huang<br />
<br />
# Disabled 2011-04-27 - blank feed, aged blod<br />
#[http://qwu26.blogspot.com/feeds/posts/default/-/OOP344]<br />
#name=Qingxi Wu<br />
<br />
# Disabled 2011-04-27 - blank blog<br />
#[http://lwang162.blogspot.com/feeds/posts/default/-/OOP344]<br />
#name=LianHe Wang<br />
<br />
# Disabled 2011-04-27 - blank blog, aged<br />
#[http://bmcohen.blogspot.com/feeds/posts/default/-/seneca]<br />
#name=Bryan Cohen<br />
<br />
[http://feliploko.wordpress.com/category/seneca/feed]<br />
name=Felipe de Oliveira<br />
<br />
# Following feed reports invalid content type.<br />
# Disabled 2010-09-23 CTyler<br />
#[http://lwang168.blogspot.com/feeds/posts/-/oop344]<br />
#name=Liang Wang<br />
<br />
[http://shunyao-cpa.blogspot.com/feeds/posts/default]<br />
name=shun yao zhang<br />
<br />
[http://galewis.blogspot.com/feeds/posts/default]<br />
name=Gustone Lewis<br />
<br />
[http://hmo6.blogspot.com/feeds/posts/default]<br />
name=Mo Hsiu Mei<br />
<br />
[http://derekambrose.blogspot.com/feeds/posts/default/-/open%20source]<br />
name=Derek Ambrose<br />
<br />
[http://scottdowne.wordpress.com/category/open-source/feed/]<br />
name=Scott Downe<br />
<br />
# Disabled 2011-04-27 - blog deleted<br />
#[http://anthonyisgood.blogspot.com/feeds/posts/default/-/open%20source]<br />
#name = Anthony Alves<br />
<br />
[http://jjleeos.blogspot.com/feeds/posts/default]<br />
name = Jeffrey Lee<br />
<br />
[http://harjinderv.tumblr.com/tagged/Open_Source/rss]<br />
name = Harjinder Virdi<br />
<br />
[http://cldenobrega.wordpress.com/category/open-source/feed/]<br />
name = Crystal de Nobrega (cldenobrega)<br />
<br />
[http://lchen97.blogspot.com/feeds/posts/default]<br />
name=Chris Chen<br />
<br />
# Parked domain. Disabled 2010-09-23 CTyler<br />
#[http://hotweiss.lifeflayer.com/?feed=atom]<br />
#name=Tianqi Liu<br />
<br />
[http://oleg-oop.blogspot.com/feeds/posts/default]<br />
name=Aleh Pliats<br />
<br />
[http://88mishok.blogspot.com/feeds/posts/default]<br />
name=Francois Des Jarlais<br />
<br />
[http://bikarin.blogspot.com/feeds/posts/default]<br />
name=Irina Balzamova<br />
<br />
[http://mashhaque.blogspot.com/feeds/posts/default]<br />
name=Mashfique Haque<br />
<br />
[http://yxue11.blogspot.com/feeds/posts/default]<br />
name=Yong Xue<br />
<br />
[http://tdao75.blogspot.com/feeds/posts/default]<br />
name=Thanh Dao<br />
<br />
[http://minooz.wordpress.com/category/CDOT/feed/]<br />
name=Minoo Ziaei<br />
<br />
[http://gbatumbya.wordpress.com/category/seneca/cdot/feed/]<br />
name=Grace Simon Batumbya<br />
<br />
[http://sonnilion.wordpress.com/feed/]<br />
name=Matt Postill<br />
<br />
[http://acchung1.blogspot.com/feeds/posts/default/-/oop344]<br />
name=Alex Chun Yang Chung<br />
<br />
[http://hckim.wordpress.com/category/open-source/feed/]<br />
name=Han Chul Kim<br />
<br />
[http://xizhangblog.blogspot.com/feeds/posts/default/-/oop344]<br />
name=Xi Zhang<br />
<br />
# Modified 2011-04-27 - changed from blank category<br />
[http://lwu11.blogspot.com/feeds/posts/default]<br />
name=Ling Wu<br />
<br />
[http://jasonquan.wordpress.com/category/OOP344/feed/]<br />
name=Jason Quan<br />
<br />
[http://myoop344blog.blogspot.com/feeds/posts/default/]<br />
name=Xiongwen LU<br />
<br />
[http://0zzym.wordpress.com/feed]<br />
name=Osman Mirza<br />
<br />
[http://adgezaza.posterous.com/rss.xml?tag=open%20source]<br />
name=Adrian Maurer<br />
<br />
[http://kumailhabib.blogspot.com/feeds/posts/default]<br />
name=Kumail Habib<br />
<br />
[http://imadorki3.blogspot.com/feeds/posts/default]<br />
name=Robin Co<br />
<br />
[http://danapao026.blogspot.com/feeds/posts/default]<br />
name=Don Armin Napao<br />
<br />
[http://cgm087.blogspot.com/feeds/posts/default/-/CDOT]<br />
name=Christopher G. Missen<br />
<br />
# Disabled 2011-04-27 - password-protected now and not valid<br />
#[http://yujinjeong.wordpress.com/category/GAM666/feed/]<br />
#name=YuJin Jeong<br />
<br />
[http://crgosselin.blogspot.com/feeds/posts/default]<br />
name=Chris Ryan Gosselin<br />
<br />
[http://slaw12.wordpress.com/feed/ ]<br />
name=Stephanie Law<br />
<br />
[http://ysliu2.blogspot.com/feeds/posts/default]<br />
name=Yansong Liu<br />
<br />
[http://www.drizhepolov.com/blog/?feed=rss2]<br />
name=Vladimir Drizhepolov<br />
<br />
[http://bhavanesh.wordpress.com/feed/]<br />
name=Bhavanesh Patel<br />
<br />
[http://xwu0102.blogspot.com/feeds/posts/default/-/oop344]<br />
name=Xiaojiang Wu<br />
<br />
[http://rhui4.wordpress.com/feed/ ]<br />
name=Richard Hui<br />
<br />
[http://invinciblyignorant.wordpress.com/category/OOP344/feed/]<br />
name=Jason Burton<br />
<br />
[http://goldenration.wordpress.com/feed/]<br />
name=HongGeun Park<br />
<br />
[http://thupten.veryusefulinfo.com/?feed=rss2]<br />
name=Thupten Choephel<br />
<br />
[http://priyadeep.wordpress.com/feed/]<br />
name=Priyadeep Gill<br />
<br />
[http://kyle205website.info/wordpress/?feed=rss2]<br />
name=Khai Huynh<br />
<br />
[http://dkxy.net/blog/tag/oop344/feed/]<br />
name=Dale Karp<br />
<br />
[http://vbluzmans.wordpress.com/feed/]<br />
name=Vitaly Bluzmans<br />
<br />
[http://akkimblog.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Kerry Taylor<br />
<br />
<br />
[http://alf1488.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Yegor Tyunin<br />
<br />
[http://sbr600.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Matthew Ortofsky<br />
<br />
[http://pbrown9.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Paul Brown<br />
<br />
[http://jzaidi.wordpress.com/feed/]<br />
name=Jawwad Zaidi<br />
<br />
[https://rainulf.ca/rss.php?tags=cdot]<br />
name=Jose Rainulf Pineda<br />
<br />
[http://donchel.wordpress.com/feed/]<br />
name=Dong Cheol Cha<br />
<br />
[http://sweerdenburg.wordpress.com/category/seneca/feed/]<br />
name=Steven Weerdenburg<br />
<br />
[http://jyang42.blogspot.com/feeds/posts/default]<br />
name=Jing Yang<br />
<br />
[http://tarinc.wordpress.com/feed/]<br />
name=Tarin Choudhury<br />
<br />
[http://jtdonaldson21.blogspot.com/feeds/posts/default]<br />
name=Jeshu Donaldson<br />
<br />
[http://bccp32.blogspot.com/feeds/posts/default]<br />
name=Yauheni Khabian<br />
<br />
[http://mark-os.blogspot.com/feeds/posts/default]<br />
name=Mark Eamiguel<br />
<br />
[http://kweber1.blogspot.com/feeds/posts/default]<br />
name=Kyle Weber<br />
<br />
[http://mustafaredha.wordpress.com/category/planet-cdot/feed]<br />
name=Mustafa Redha<br />
<br />
[http://andrewasdesigned.blogspot.com/feeds/posts/default/-/SBR600]<br />
name=Andrew Singh<br />
<br />
[http://escom0.blogspot.com/feeds/posts/default]<br />
name=Eric Shum<br />
<br />
# Disabled 2011-04-27 - blog was deleted<br />
#[http://open-ht.blogspot.com/feeds/posts/default]<br />
#name=Hoc Tran<br />
<br />
[http://dvkitancheva.wordpress.com/feed/]<br />
name=Denitsa Kitancheva<br />
<br />
[http://vanjason.wordpress.com/category/sbr600/feed]<br />
name=Jason Van<br />
<br />
[http://kpangilinan.wordpress.com/feed]<br />
name=Kenneth Pangilinan<br />
<br />
[http://ajcondinho.blogspot.com/feeds/posts/default/-/opensource]<br />
name=Andrew Condinho<br />
<br />
[http://blog.esmnetworks.com/category/planet-cdot/feed]<br />
name=Adrian Pruteanu<br />
<br />
[http://stevebologna.wordpress.com/category/Open-Source/feed/]<br />
name=Stephen Bologna<br />
<br />
[http://www.winterleaf.ca/blog/category/oop344/feed/]<br />
name=Daniel Slessarev<br />
<br />
[http://ycshon.blogspot.com/feeds/posts/default]<br />
name=Young Chol Shon<br />
<br />
[http://jwpark2.blogspot.com/feeds/posts/default]<br />
name=Jaewoo Park<br />
<br />
[http://klasconia.wordpress.com/feed/]<br />
name=Kevin Lasconia<br />
<br />
[http://kmcdonald11.blogspot.com/feeds/posts/default]<br />
name=Kaitlyn McDonald<br />
<br />
[http://jrobinson7.wordpress.com/feed/]<br />
name=James Robinson<br />
<br />
[http://trusu.blogspot.com/feeds/posts/default]<br />
name=Traian Rusu<br />
<br />
[http://blockrockinpete.blogspot.com/feeds/posts/default/-/OSD600]<br />
name=Pete Leaning<br />
<br />
[http://tyler-taehee-lee.blogspot.com/feeds/posts/default/-/SBR600]<br />
name=Tae Hee Lee<br />
<br />
[http://www.kaitlyncallow.com/Blog/?feed=rss2&cat=86]<br />
name=Kaitlyn Callow<br />
face=http://www.kaitlyncallow.com/Dump/kait_avatar.jpg<br />
<br />
[http://saad-husain.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Saad Husain<br />
<br />
[http://jevangelos.wordpress.com/feed/]<br />
name=James Evangelista<br />
<br />
# Disabled 2011-04-27 - not a feed link<br />
#[http://sajed481.wordpress.com/SBR600/]<br />
#name=M.A Sajed Shadani<br />
<br />
[http://rizwanhaq.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Rizwan Haq<br />
<br />
[http://tuori.tk/blog/blogs/blog1.php?tempskin=_rss2&cat=15]<br />
name=Matthew Tuori<br />
<br />
[http://ktaraghi.blogspot.com/feeds/posts/default]<br />
name=Khosro Taraghi<br />
<br />
[http://opensourceftw.blogspot.com/feeds/posts/default?alt=rss]<br />
name=Anthony Boccia<br />
<br />
[http://perfectlylogical.wordpress.com/category/sbr600/feed/]<br />
name=Stephen Hall<br />
<br />
[http://rocellaj.wordpress.com/feed/]<br />
name=Rocella Jimenez<br />
<br />
[http://justinpaulmorgan.blogspot.com/feeds/posts/default]<br />
name=Justin Morgan<br />
<br />
[http://gcasella.blogspot.com/feeds/posts/default]<br />
name=Gian-Luca Casella<br />
<br />
[http://pratikamin.wordpress.com/category/sbr600/feed/]<br />
name=Pratik Amin<br />
<br />
[http://syang00.wordpress.com/feed/]<br />
name=Stephanie Yang<br />
<br />
[http://tewestacott.wordpress.com/category/SBR600/feed/]<br />
name=Todd Westacott<br />
<br />
[http://aparda.wordpress.com/category/SBR600//feed/]<br />
name=Andrew Parda<br />
<br />
[http://gjuhasz1.wordpress.com/feed/]<br />
name=Gergely Juhasz<br />
<br />
[http://completefail.wordpress.com/category/SBR600/feed/]<br />
name=Joshua Y. Koh<br />
<br />
[http://myuberwebsite.blogspot.com/feeds/posts/default]<br />
name=Dmitry Artemenko<br />
<br />
[http://cgomes7.wordpress.com/feed/]<br />
name=Cesar Gomes<br />
<br />
[http://supbroseph.wordpress.com/feed/]<br />
name=Houssam haidar<br />
<br />
[http://www.bradchen.com/rss/blog/open%20source]<br />
name=Brad Chen (vvasabi)<br />
<br />
[http://asabir.wordpress.com/feed/]<br />
name=Adeel Sabir (asabir)<br />
<br />
[http://libresparks.wordpress.com/category/SBR600/feed/]<br />
name=Alfred Liu<br />
<br />
[http://acook6.blogspot.com/feeds/posts/default/-/open-source]<br />
name=Alan Cook<br />
<br />
[http://coding.shaunofthelive.com/feeds/posts/default/-/oop344]<br />
name=Shaun Hill<br />
<br />
[http://maoli1207.blogspot.com/feeds/posts/default/-/open-source]<br />
name=Mao Hua Li<br />
<br />
[http://fossjon.wordpress.com/feed/]<br />
name=Jon Chiappetta<br />
<br />
[http://dperit.blogspot.com/feeds/posts/default/-/cdot]<br />
name=David Perit<br />
<br />
[http://szafar8.wordpress.com/tag/cdot/feed/]<br />
name=Salman Zafar<br />
<br />
[http://mbuttu.wordpress.com/category/Open-Source/feed/]<br />
name=Mohammed Buttu<br />
<br />
[http://brianlimtemp.blogspot.com/feeds/posts/default/-/CDOT]<br />
name=Brian Lim<br />
</pre></div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62632Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-13T01:38:15Z<p>Ladanzahir: /* 11.2 Create Database File */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Add SDCard to Simulator===<br />
To be able to have data preserved on database, first we need to make sure that simulator can simulate SDCard, so that we can run our application with database. For this purpose first create a folder on your file system. Then run the simulator and from the top menu choose: Simulate > Change SD Card... .<br/><br />
Then Mount Directory, and select the folder you just created. Every time you restart the simulator, before running the app you need to make sure that the folder is mounted as SD Card. later on you will see that the database file gets created there.<br/><br />
[[Image: BB_SDCard.png | 350px]]<br/><br />
<br />
===11.2 Create Database File===<br />
We would like to create a database file including our Student Entity, so that we can put it in the project. Then every time the app runs, first it checks if it is the first time run of the app on the device or simulator. If so, the app will copy the file in to the SDCard. Next time that you run the application, it will know that the file is there, so will not override it. <Br/><br />
<br />
For this purpose, create a simple blackberry project with only the application object. We do not need any screen here. call it "DBCreator".<br />
and this will need to only have a class called MyApp.java which extends UIApplication. Here is the code for this class:<br />
<br />
<source lang="java" ><br />
<br />
package mypackage;<br />
<br />
import java.util.Enumeration;<br />
import javax.microedition.io.file.FileSystemRegistry;<br />
import net.rim.device.api.ui.*;<br />
import net.rim.device.api.ui.component.*;<br />
import net.rim.device.api.database.*;<br />
import net.rim.device.api.io.*;<br />
<br />
/**<br />
* This class extends the UiApplication class, providing a<br />
* graphical user interface.<br />
*/<br />
public class MyApp extends UiApplication<br />
{<br />
private static String DB_NAME = "SQLiteStudentList";<br />
<br />
/**<br />
* Entry point for application<br />
* @param args Command line arguments (not used)<br />
*/<br />
public static void main(String[] args) throws Exception<br />
{<br />
// Create a new instance of the application and make the currently<br />
// running thread the application's event dispatch thread.<br />
MyApp theApp = new MyApp(); <br />
theApp.enterEventDispatcher();<br />
}<br />
<br />
<br />
/**<br />
* Creates a new MyApp object<br />
*/<br />
public MyApp()throws Exception<br />
{ <br />
// Check for the presence of the SDCard<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
try{<br />
// create a URI object with te file name and location <br />
String dbLocation = "/SDCard/databases/DBCreator/";<br />
URI uri = URI.create(dbLocation + DB_NAME);<br />
<br />
// open a database connection to that URI<br />
Database db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false));<br />
<br />
// create the table if it does not already exist<br />
Statement statement =<br />
db.createStatement("CREATE TABLE IF NOT EXISTS Student(id INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT, email TEXT, address TEXT)");<br />
statement.prepare();<br />
<br />
//execute the statement<br />
statement.execute();<br />
<br />
// close statement and database<br />
statement.close(); <br />
db.close(); <br />
<br />
}catch(Exception ex ) {<br />
errorDialog(ex.getMessage());<br />
System.exit(0); <br />
}<br />
<br />
}<br />
}<br />
<br />
// Error message dialog<br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
}<br />
<br />
</source><br />
<br />
Now run tha application. Then from the SDCard folder, drag the database file and drop it into your main project, "res" folder.<br />
<br />
===11.3 Add id to Student Class===<br />
Now in our main application project,we need to add id to this class because we are going to preserve our Student objects in database,:<br />
So add a private field and add public getter and setters:<br />
<source lang="java"><br />
<br />
public int getId(){<br />
return this.id;<br />
}<br />
public void setId(int id){<br />
this.id = id;<br />
}<br />
</source><br />
<br />
===11.4 Check for presence of SDCard===<br />
Each time our "Student View" application runs, we have to check for the presence of the SD card, and if it does not exist, we have to show a dialog message.<br />
<br />
Therefore, add the following code to the ViewStudentApp.java class constructor:<br />
<source lang="java"><br />
<br />
public ViewStudentApp() throws Exception {<br />
//This part is from BB Sample application<br />
// Determine if an SDCard is present<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
<br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
// the rest of code goes here<br />
<br />
}<br />
</source><br />
<br />
===11.5 Copy Database File into SDCard===<br />
Now that application knows SDCard is present, It should check if the database file exist, otherwise copy it from the application bundle into SDCard:<br />
<source lang="java"><br />
else<br />
{<br />
String dbLocation = "/SDCard/databases/StudentsList/";<br />
<br />
// Create URI <br />
uri = URI.create(dbLocation + DB_NAME); <br />
<br />
// Open or create a plain text database. This will create the<br />
// directory and file defined by the URI (if they do not already exist).<br />
db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false)); <br />
<br />
// Close the database in case it is blank and we need to write to the file<br />
db.close();<br />
<br />
// Open a connection to the database file <br />
FileConnection fileConnection = (FileConnection)Connector.open("file://" + dbLocation + DB_NAME); <br />
<br />
// If the file is blank, copy the pre-defined database from this<br />
// module to the SDCard.<br />
if(fileConnection.exists() && fileConnection.fileSize() == 0)<br />
{ <br />
readAndWriteDatabaseFile(fileConnection); <br />
} <br />
<br />
// notice that the way we are callling the StudentList constructor is now different.<br />
// Later on you will see that we should modify that class:<br />
_studentList = new StudentList(db, uri);<br />
<br />
// here goes the rest of the constructor code<br />
</source><br />
<br />
Then add the following method (readAndWriteDatabaseFile) to the file that actually reads the database file and puts it into the simulator:<br />
<source lang="java"><br />
public void readAndWriteDatabaseFile(FileConnection fileConnection) throws IOException<br />
{ <br />
OutputStream outputStream = null;<br />
InputStream inputStream = null; <br />
<br />
// Open an input stream to the pre-defined encrypted database bundled<br />
// within this module.<br />
inputStream = getClass().getResourceAsStream("/" + DB_NAME);<br />
<br />
// Open an output stream to the newly created file<br />
outputStream = (OutputStream)fileConnection.openOutputStream(); <br />
<br />
// Read data from the input stream and write the data to the<br />
// output stream. <br />
byte[] data = new byte[256];<br />
int length = 0;<br />
while (-1 != (length = inputStream.read(data)))<br />
{<br />
outputStream.write(data, 0, length); <br />
} <br />
<br />
// Close the connections<br />
if(fileConnection != null)<br />
{<br />
fileConnection.close();<br />
}<br />
if(outputStream != null)<br />
{<br />
outputStream.close();<br />
}<br />
if(inputStream != null)<br />
{<br />
inputStream.close();<br />
} <br />
}<br />
<br />
</source><br />
<br />
===11.6 Create SQLiteManager Class===<br />
<br />
Now we need a class that will be the only class interacting with our database. It will take a Database object and a URI object to open database in the constructor. It will have methods to perform all the queries we need and at the end of each query will close the database. <br/><br />
<br />
So, create a class called: SQLiteManager, with 2 private fields, and a constructor that sets them and then tries to open database:<br />
<source lang="java"><br />
<br />
package cs.ecl.team1.project;<br />
<br />
<br />
<br />
import java.util.Vector;<br />
import net.rim.device.api.database.Cursor;<br />
import net.rim.device.api.database.DataTypeException;<br />
import net.rim.device.api.database.Database;<br />
import net.rim.device.api.database.DatabaseException;<br />
import net.rim.device.api.database.DatabaseFactory;<br />
import net.rim.device.api.database.Row;<br />
import net.rim.device.api.database.Statement;<br />
import net.rim.device.api.io.URI;<br />
import net.rim.device.api.ui.UiApplication;<br />
import net.rim.device.api.ui.component.Dialog;<br />
<br />
public class SQLManager {<br />
<br />
private static Database db;<br />
private URI uri;<br />
<br />
public SQLManager(Database db, URI uri)<br />
{<br />
this.uri = uri;<br />
this.db = db;<br />
openDB();<br />
}<br />
<br />
}<br />
</source><br />
'''11.6.1 Open Database'''<br/><br />
Then we implement the openDB() method:<br />
<source lang="java"><br />
void openDB()<br />
{ <br />
try<br />
{ <br />
this.db = DatabaseFactory.open(uri);<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
} <br />
</source><br />
'''11.6.2 Close Database'''<br/><br />
Then we definitely need a closeDB() method to use later:<br />
<source lang="java"><br />
static void closeDB()<br />
{ <br />
try<br />
{ <br />
db.close();<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
} <br />
</source><br />
And as you noticed above, we are going to need a method called errorDialog():<br />
<source lang="java"><br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
</source><br />
'''11.6.3 Insert New Student'''<br/><br />
The first query we need is a query that enables us add a new Student, so we need to implement a method for that:<br />
<source lang="java"><br />
//ADD STUDENT<br />
Student addStudent(String fName, String lName, String email, String address){<br />
Student student = null;<br />
try<br />
{<br />
<br />
<br />
Statement statement = db.createStatement("INSERT INTO Student VALUES(NULL,?,?,?,?)"); <br />
statement.prepare(); <br />
<br />
statement.bind(1,fName);<br />
statement.bind(2, lName);<br />
statement.bind(3, email);<br />
statement.bind(4, address);<br />
<br />
statement.execute();<br />
statement.close();<br />
<br />
statement = db.createStatement("SELECT id FROM Student WHERE firstName = ? AND lastName = ?");<br />
statement.prepare();<br />
statement.bind(1, fName); <br />
statement.bind(2, lName);<br />
Cursor cursor = statement.getCursor(); <br />
if(cursor.next())<br />
{<br />
Row row = cursor.getRow();<br />
int id = row.getInteger(0); <br />
student = new Student(id, fName, lName, email, address); <br />
} <br />
cursor.close();<br />
statement.close();<br />
}catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
} <br />
catch(DataTypeException dte)<br />
{<br />
errorDialog(dte.toString());<br />
}<br />
<br />
return student;<br />
}<br />
</source><br />
<br />
'''11.6.4 Delete Student'''<br/><br />
Then add a method to delete student by id:<br />
<br />
<source lang="java"><br />
// DELETE STUDENT<br />
<br />
void deleteStudent(int id)<br />
{<br />
try<br />
{<br />
<br />
Statement statement = db.createStatement("DELETE FROM Student WHERE id = ?");<br />
statement.prepare(); <br />
statement.bind(1, id);<br />
statement.execute(); <br />
statement.close();<br />
<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
} <br />
} <br />
</source><br />
'''11.6.5 Update Student'''<br/><br />
And a method to update Student:<br />
<source lang="java"><br />
//UPDATE STUDENT<br />
void updateStudent(int id, String fName, String lName, String email, String address)<br />
{<br />
try<br />
{ <br />
Statement statement = db.createStatement("UPDATE Student SET firstName = ?, lastName= ?, email = ?, address = ? WHERE id = ?");<br />
statement.prepare(); <br />
statement.bind(1, fName);<br />
statement.bind(2, lName);<br />
statement.bind(3, email);<br />
statement.bind(4, address);<br />
statement.bind(5, id); <br />
statement.execute(); <br />
statement.close();<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString()); <br />
} <br />
}<br />
<br />
</source><br />
<br />
'''11.6.6 Select All Students'''<br/><br />
And obviously we will need a method that gets all the students from database and returns a vector of Student, so that we can populate our student list:<br />
<source lang="java"><br />
Vector getStudents(){<br />
Vector students= new Vector();<br />
<br />
try<br />
{ <br />
<br />
Statement statement = db.createStatement("SELECT * FROM Student");<br />
statement.prepare();<br />
Cursor cursor = statement.getCursor();<br />
<br />
// Iterate through the the result set. For each row, add a<br />
// new DirectoryItem object to the vector.<br />
while(cursor.next())<br />
{ <br />
Row row = cursor.getRow();<br />
<br />
int id = row.getInteger(0);<br />
<br />
String fName = row.getString(1);<br />
String lName = row.getString(2);<br />
String email = row.getString(3); <br />
String address = row.getString(4);<br />
<br />
Student student = new Student(id, fName, lName, email, address);<br />
students.addElement(student); <br />
}<br />
statement.close();<br />
cursor.close();<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
catch(DataTypeException dte)<br />
{<br />
errorDialog(dte.toString());<br />
} <br />
<br />
return students; <br />
<br />
}<br />
</source><br />
<br />
===11.7 Modify StudentsList Class to use SQLiteManager===<br />
So far the StudentList class we have, consumes a vector to store students whiche are note preserved. We will modify the methods of this list to use the SQLiteManager and preserve the objects.<br/><br />
Add the following private fields to the StudentList Class:<br />
<source lang="java"><br />
private Database db ;<br />
private URI uri;<br />
</source><br />
Then modify its constructor to take and set thode fields:<br />
<source lang="java"><br />
public StudentList(Database db, URI uri) throws Exception {<br />
super(new StudentListComparator());<br />
this.db = db;<br />
this.uri = uri;<br />
SQLManager sqlManager = new SQLManager(db, uri);<br />
loadFrom(sqlManager.getStudents().elements()); <br />
SQLManager.closeDB();<br />
}<br />
<br />
</source><br />
<br />
'''11.7.1 Load list'''<br/><br />
As noticed above, the constructor then passes those objects to a new SQLiteManager object and gets students from the manager to load the list with. Then it closes the database.<br/><br />
<br />
'''11.7.2 Add Student'''<br/><br />
Now modify the addElement method:<br />
<source lang="java"><br />
/**<br />
* Adds a new element to the list.<br />
* @param element The element to be added.<br />
*/<br />
void addElement(Object element) {<br />
Student student = (Student) element;<br />
SQLManager sqlManager = new SQLManager(db, uri);<br />
sqlManager.addStudent(student.getFirstname(), student.getLastName(), student.getEmail(), student.getAddress());<br />
doAdd(element);<br />
SQLManager.closeDB();<br />
}<br />
<br />
</source><br />
'''11.7.3 Edit Student'''<br/><br />
And editElement method:<br />
<source lang="java"><br />
// added for Update:<br />
void updateElement(Object oldElement, Object newElement){<br />
Student student = (Student) newElement;<br />
SQLManager sqlManager = new SQLManager(db, uri);<br />
sqlManager.updateStudent(student.getId(), student.getFirstname(), student.getLastName(), student.getEmail(), student.getAddress());<br />
doUpdate(oldElement,newElement);<br />
SQLManager.closeDB();<br />
}<br />
<br />
<br />
</source><br />
'''11.7.4 Delete Student'''<br/><br />
<source lang="java"><br />
/**<br />
* Removes element from the list<br />
* @param element<br />
*/<br />
void deleteElement(Object element) {<br />
Student student = (Student)element;<br />
SQLManager sqlManager = new SQLManager(db, uri);<br />
sqlManager.deleteStudent(student.getId());<br />
doRemove(element);<br />
SQLManager.closeDB();<br />
}<br />
<br />
</source><br />
<br />
===11.8 Run Student View Application ===<br />
Now if you run the application, you will get the same functionality as before, but this time data is saved. Don't forget to add SDCard to simulator before running it.</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=RCP_:_Tutorials&diff=62629RCP : Tutorials2011-04-13T01:29:37Z<p>Ladanzahir: </p>
<hr />
<div>{{Ecl_r|RCP|Tutorials}}<br />
<br />
<br />
{{Ecl_r_entry |c=0<br />
|url= https://zenit.senecac.on.ca/~ecl500_111a11/labs/RCP-tutorial/<br />
|title= Team 5 - RCP lab<br />
|descr= *Create RCP Application to Connect Oracle Database<br />
<br />
}}<br />
<br />
{{Ecl_r_entry |c=0<br />
|url= http://zenit.senecac.on.ca/~ecl500_111a06/labs/lab3.html<br />
|title= RCP Lab - Team 7 DPS914; Winter 2011<br />
|descr= * Create a RCP application * Define and use commands * Define and use editors * Use JFace Viewers * Create a configuration for your application }}<br />
<br />
{{Ecl_r_entry |c=0<br />
|url= http://zenit.senecac.on.ca/wiki/index.php/Teams_Winter_2011/team1<br />
|title= Team 1 - RCP lab<br />
|descr= *Create RCP Application to Maintain Student Records<br />
<br />
}}</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62376Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-12T04:34:34Z<p>Ladanzahir: /* 11.8 Student View Application in Action */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Add SDCard to Simulator===<br />
To be able to have data preserved on database, first we need to make sure that simulator can simulate SDCard, so that we can run our application with database. For this purpose first create a folder on your file system. Then run the simulator and from the top menu choose: Simulate > Change SD Card... .<br/><br />
Then Mount Directory, and select the folder you just created. Every time you restart the simulator, before running the app you need to make sure that the folder is mounted as SD Card. later on you will see that the database file gets created there.<br/><br />
[[Image: BB_SDCard.png | 350px]]<br/><br />
<br />
===11.2 Create Database File===<br />
We would like to create a database file including out Student Entity, so that we can put it in the project. Then every time the app runs, first it checks if it is the first time run of the app on the device or simulator. If so, the app will copy the file in to the SDCard. Next time that you run the application, it will know that the file is there, so will not override it. <Br/><br />
<br />
For this purpose, create a simple blackberry project with only the application object. We do not need any screen here. call it "DBCreator".<br />
and this will need to only have a class called MyApp.java which extends UIApplication. Here is the code for this class:<br />
<br />
<source lang="java" ><br />
<br />
package mypackage;<br />
<br />
import java.util.Enumeration;<br />
import javax.microedition.io.file.FileSystemRegistry;<br />
import net.rim.device.api.ui.*;<br />
import net.rim.device.api.ui.component.*;<br />
import net.rim.device.api.database.*;<br />
import net.rim.device.api.io.*;<br />
<br />
/**<br />
* This class extends the UiApplication class, providing a<br />
* graphical user interface.<br />
*/<br />
public class MyApp extends UiApplication<br />
{<br />
private static String DB_NAME = "SQLiteStudentList";<br />
<br />
/**<br />
* Entry point for application<br />
* @param args Command line arguments (not used)<br />
*/<br />
public static void main(String[] args) throws Exception<br />
{<br />
// Create a new instance of the application and make the currently<br />
// running thread the application's event dispatch thread.<br />
MyApp theApp = new MyApp(); <br />
theApp.enterEventDispatcher();<br />
}<br />
<br />
<br />
/**<br />
* Creates a new MyApp object<br />
*/<br />
public MyApp()throws Exception<br />
{ <br />
// Check for the presence of the SDCard<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
try{<br />
// create a URI object with te file name and location <br />
String dbLocation = "/SDCard/databases/DBCreator/";<br />
URI uri = URI.create(dbLocation + DB_NAME);<br />
<br />
// open a database connection to that URI<br />
Database db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false));<br />
<br />
// create the table if it does not already exist<br />
Statement statement =<br />
db.createStatement("CREATE TABLE IF NOT EXISTS Student(id INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT, email TEXT, address TEXT)");<br />
statement.prepare();<br />
<br />
//execute the statement<br />
statement.execute();<br />
<br />
// close statement and database<br />
statement.close(); <br />
db.close(); <br />
<br />
}catch(Exception ex ) {<br />
errorDialog(ex.getMessage());<br />
System.exit(0); <br />
}<br />
<br />
}<br />
}<br />
<br />
// Error message dialog<br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
}<br />
<br />
</source><br />
<br />
Now run tha application. Then from the SDCard folder, drag the database file and drop it into your main project, "res" folder.<br />
<br />
===11.3 Add id to Student Class===<br />
Now in our main application project,we need to add id to this class because we are going to preserve our Student objects in database,:<br />
So add a private field and add public getter and setters:<br />
<source lang="java"><br />
<br />
public int getId(){<br />
return this.id;<br />
}<br />
public void setId(int id){<br />
this.id = id;<br />
}<br />
</source><br />
<br />
===11.4 Check for presence of SDCard===<br />
Each time our "Student View" application runs, we have to check for the presence of the SD card, and if it does not exist, we have to show a dialog message.<br />
<br />
Therefore, add the following code to the ViewStudentApp.java class constructor:<br />
<source lang="java"><br />
<br />
public ViewStudentApp() throws Exception {<br />
//This part is from BB Sample application<br />
// Determine if an SDCard is present<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
<br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
// the rest of code goes here<br />
<br />
}<br />
</source><br />
<br />
===11.5 Copy Database File into SDCard===<br />
Now that application knows SDCard is present, It should check if the database file exist, otherwise copy it from the application bundle into SDCard:<br />
<source lang="java"><br />
else<br />
{<br />
String dbLocation = "/SDCard/databases/StudentsList/";<br />
<br />
// Create URI <br />
uri = URI.create(dbLocation + DB_NAME); <br />
<br />
// Open or create a plain text database. This will create the<br />
// directory and file defined by the URI (if they do not already exist).<br />
db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false)); <br />
<br />
// Close the database in case it is blank and we need to write to the file<br />
db.close();<br />
<br />
// Open a connection to the database file <br />
FileConnection fileConnection = (FileConnection)Connector.open("file://" + dbLocation + DB_NAME); <br />
<br />
// If the file is blank, copy the pre-defined database from this<br />
// module to the SDCard.<br />
if(fileConnection.exists() && fileConnection.fileSize() == 0)<br />
{ <br />
readAndWriteDatabaseFile(fileConnection); <br />
} <br />
<br />
// notice that the way we are callling the StudentList constructor is now different.<br />
// Later on you will see that we should modify that class:<br />
_studentList = new StudentList(db, uri);<br />
<br />
// here goes the rest of the constructor code<br />
</source><br />
<br />
Then add the following method (readAndWriteDatabaseFile) to the file that actually reads the database file and puts it into the simulator:<br />
<source lang="java"><br />
public void readAndWriteDatabaseFile(FileConnection fileConnection) throws IOException<br />
{ <br />
OutputStream outputStream = null;<br />
InputStream inputStream = null; <br />
<br />
// Open an input stream to the pre-defined encrypted database bundled<br />
// within this module.<br />
inputStream = getClass().getResourceAsStream("/" + DB_NAME);<br />
<br />
// Open an output stream to the newly created file<br />
outputStream = (OutputStream)fileConnection.openOutputStream(); <br />
<br />
// Read data from the input stream and write the data to the<br />
// output stream. <br />
byte[] data = new byte[256];<br />
int length = 0;<br />
while (-1 != (length = inputStream.read(data)))<br />
{<br />
outputStream.write(data, 0, length); <br />
} <br />
<br />
// Close the connections<br />
if(fileConnection != null)<br />
{<br />
fileConnection.close();<br />
}<br />
if(outputStream != null)<br />
{<br />
outputStream.close();<br />
}<br />
if(inputStream != null)<br />
{<br />
inputStream.close();<br />
} <br />
}<br />
<br />
</source><br />
<br />
===11.6 Create SQLiteManager Class===<br />
<br />
Now we need a class that will be the only class interacting with our database. It will take a Database object and a URI object to open database in the constructor. It will have methods to perform all the queries we need and at the end of each query will close the database. <br/><br />
<br />
So, create a class called: SQLiteManager, with 2 private fields, and a constructor that sets them and then tries to open database:<br />
<source lang="java"><br />
<br />
package cs.ecl.team1.project;<br />
<br />
<br />
<br />
import java.util.Vector;<br />
import net.rim.device.api.database.Cursor;<br />
import net.rim.device.api.database.DataTypeException;<br />
import net.rim.device.api.database.Database;<br />
import net.rim.device.api.database.DatabaseException;<br />
import net.rim.device.api.database.DatabaseFactory;<br />
import net.rim.device.api.database.Row;<br />
import net.rim.device.api.database.Statement;<br />
import net.rim.device.api.io.URI;<br />
import net.rim.device.api.ui.UiApplication;<br />
import net.rim.device.api.ui.component.Dialog;<br />
<br />
public class SQLManager {<br />
<br />
private static Database db;<br />
private URI uri;<br />
<br />
public SQLManager(Database db, URI uri)<br />
{<br />
this.uri = uri;<br />
this.db = db;<br />
openDB();<br />
}<br />
<br />
}<br />
</source><br />
'''11.6.1 Open Database'''<br/><br />
Then we implement the openDB() method:<br />
<source lang="java"><br />
void openDB()<br />
{ <br />
try<br />
{ <br />
this.db = DatabaseFactory.open(uri);<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
} <br />
</source><br />
'''11.6.2 Close Database'''<br/><br />
Then we definitely need a closeDB() method to use later:<br />
<source lang="java"><br />
static void closeDB()<br />
{ <br />
try<br />
{ <br />
db.close();<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
} <br />
</source><br />
And as you noticed above, we are going to need a method called errorDialog():<br />
<source lang="java"><br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
</source><br />
'''11.6.3 Insert New Student'''<br/><br />
The first query we need is a query that enables us add a new Student, so we need to implement a method for that:<br />
<source lang="java"><br />
//ADD STUDENT<br />
Student addStudent(String fName, String lName, String email, String address){<br />
Student student = null;<br />
try<br />
{<br />
<br />
<br />
Statement statement = db.createStatement("INSERT INTO Student VALUES(NULL,?,?,?,?)"); <br />
statement.prepare(); <br />
<br />
statement.bind(1,fName);<br />
statement.bind(2, lName);<br />
statement.bind(3, email);<br />
statement.bind(4, address);<br />
<br />
statement.execute();<br />
statement.close();<br />
<br />
statement = db.createStatement("SELECT id FROM Student WHERE firstName = ? AND lastName = ?");<br />
statement.prepare();<br />
statement.bind(1, fName); <br />
statement.bind(2, lName);<br />
Cursor cursor = statement.getCursor(); <br />
if(cursor.next())<br />
{<br />
Row row = cursor.getRow();<br />
int id = row.getInteger(0); <br />
student = new Student(id, fName, lName, email, address); <br />
} <br />
cursor.close();<br />
statement.close();<br />
}catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
} <br />
catch(DataTypeException dte)<br />
{<br />
errorDialog(dte.toString());<br />
}<br />
<br />
return student;<br />
}<br />
</source><br />
<br />
'''11.6.4 Delete Student'''<br/><br />
Then add a method to delete student by id:<br />
<br />
<source lang="java"><br />
// DELETE STUDENT<br />
<br />
void deleteStudent(int id)<br />
{<br />
try<br />
{<br />
<br />
Statement statement = db.createStatement("DELETE FROM Student WHERE id = ?");<br />
statement.prepare(); <br />
statement.bind(1, id);<br />
statement.execute(); <br />
statement.close();<br />
<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
} <br />
} <br />
</source><br />
'''11.6.5 Update Student'''<br/><br />
And a method to update Student:<br />
<source lang="java"><br />
//UPDATE STUDENT<br />
void updateStudent(int id, String fName, String lName, String email, String address)<br />
{<br />
try<br />
{ <br />
Statement statement = db.createStatement("UPDATE Student SET firstName = ?, lastName= ?, email = ?, address = ? WHERE id = ?");<br />
statement.prepare(); <br />
statement.bind(1, fName);<br />
statement.bind(2, lName);<br />
statement.bind(3, email);<br />
statement.bind(4, address);<br />
statement.bind(5, id); <br />
statement.execute(); <br />
statement.close();<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString()); <br />
} <br />
}<br />
<br />
</source><br />
<br />
'''11.6.6 Select All Students'''<br/><br />
And obviously we will need a method that gets all the students from database and returns a vector of Student, so that we can populate our student list:<br />
<source lang="java"><br />
Vector getStudents(){<br />
Vector students= new Vector();<br />
<br />
try<br />
{ <br />
<br />
Statement statement = db.createStatement("SELECT * FROM Student");<br />
statement.prepare();<br />
Cursor cursor = statement.getCursor();<br />
<br />
// Iterate through the the result set. For each row, add a<br />
// new DirectoryItem object to the vector.<br />
while(cursor.next())<br />
{ <br />
Row row = cursor.getRow();<br />
<br />
int id = row.getInteger(0);<br />
<br />
String fName = row.getString(1);<br />
String lName = row.getString(2);<br />
String email = row.getString(3); <br />
String address = row.getString(4);<br />
<br />
Student student = new Student(id, fName, lName, email, address);<br />
students.addElement(student); <br />
}<br />
statement.close();<br />
cursor.close();<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
catch(DataTypeException dte)<br />
{<br />
errorDialog(dte.toString());<br />
} <br />
<br />
return students; <br />
<br />
}<br />
</source><br />
<br />
===11.7 Modify StudentsList Class to use SQLiteManager===<br />
So far the StudentList class we have, consumes a vector to store students whiche are note preserved. We will modify the methods of this list to use the SQLiteManager and preserve the objects.<br/><br />
Add the following private fields to the StudentList Class:<br />
<source lang="java"><br />
private Database db ;<br />
private URI uri;<br />
</source><br />
Then modify its constructor to take and set thode fields:<br />
<source lang="java"><br />
public StudentList(Database db, URI uri) throws Exception {<br />
super(new StudentListComparator());<br />
this.db = db;<br />
this.uri = uri;<br />
SQLManager sqlManager = new SQLManager(db, uri);<br />
loadFrom(sqlManager.getStudents().elements()); <br />
SQLManager.closeDB();<br />
}<br />
<br />
</source><br />
<br />
'''11.7.1 Load list'''<br/><br />
As noticed above, the constructor then passes those objects to a new SQLiteManager object and gets students from the manager to load the list with. Then it closes the database.<br/><br />
<br />
'''11.7.2 Add Student'''<br/><br />
Now modify the addElement method:<br />
<source lang="java"><br />
/**<br />
* Adds a new element to the list.<br />
* @param element The element to be added.<br />
*/<br />
void addElement(Object element) {<br />
Student student = (Student) element;<br />
SQLManager sqlManager = new SQLManager(db, uri);<br />
sqlManager.addStudent(student.getFirstname(), student.getLastName(), student.getEmail(), student.getAddress());<br />
doAdd(element);<br />
SQLManager.closeDB();<br />
}<br />
<br />
</source><br />
'''11.7.3 Edit Student'''<br/><br />
And editElement method:<br />
<source lang="java"><br />
// added for Update:<br />
void updateElement(Object oldElement, Object newElement){<br />
Student student = (Student) newElement;<br />
SQLManager sqlManager = new SQLManager(db, uri);<br />
sqlManager.updateStudent(student.getId(), student.getFirstname(), student.getLastName(), student.getEmail(), student.getAddress());<br />
doUpdate(oldElement,newElement);<br />
SQLManager.closeDB();<br />
}<br />
<br />
<br />
</source><br />
'''11.7.4 Delete Student'''<br/><br />
<source lang="java"><br />
/**<br />
* Removes element from the list<br />
* @param element<br />
*/<br />
void deleteElement(Object element) {<br />
Student student = (Student)element;<br />
SQLManager sqlManager = new SQLManager(db, uri);<br />
sqlManager.deleteStudent(student.getId());<br />
doRemove(element);<br />
SQLManager.closeDB();<br />
}<br />
<br />
</source><br />
<br />
===11.8 Run Student View Application ===<br />
Now if you run the application, you will get the same functionality as before, but this time data is saved. Don't forget to add SDCard to simulator before running it.</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62375Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-12T04:31:40Z<p>Ladanzahir: /* 11.5 Copy Database File into SDCard */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Add SDCard to Simulator===<br />
To be able to have data preserved on database, first we need to make sure that simulator can simulate SDCard, so that we can run our application with database. For this purpose first create a folder on your file system. Then run the simulator and from the top menu choose: Simulate > Change SD Card... .<br/><br />
Then Mount Directory, and select the folder you just created. Every time you restart the simulator, before running the app you need to make sure that the folder is mounted as SD Card. later on you will see that the database file gets created there.<br/><br />
[[Image: BB_SDCard.png | 350px]]<br/><br />
<br />
===11.2 Create Database File===<br />
We would like to create a database file including out Student Entity, so that we can put it in the project. Then every time the app runs, first it checks if it is the first time run of the app on the device or simulator. If so, the app will copy the file in to the SDCard. Next time that you run the application, it will know that the file is there, so will not override it. <Br/><br />
<br />
For this purpose, create a simple blackberry project with only the application object. We do not need any screen here. call it "DBCreator".<br />
and this will need to only have a class called MyApp.java which extends UIApplication. Here is the code for this class:<br />
<br />
<source lang="java" ><br />
<br />
package mypackage;<br />
<br />
import java.util.Enumeration;<br />
import javax.microedition.io.file.FileSystemRegistry;<br />
import net.rim.device.api.ui.*;<br />
import net.rim.device.api.ui.component.*;<br />
import net.rim.device.api.database.*;<br />
import net.rim.device.api.io.*;<br />
<br />
/**<br />
* This class extends the UiApplication class, providing a<br />
* graphical user interface.<br />
*/<br />
public class MyApp extends UiApplication<br />
{<br />
private static String DB_NAME = "SQLiteStudentList";<br />
<br />
/**<br />
* Entry point for application<br />
* @param args Command line arguments (not used)<br />
*/<br />
public static void main(String[] args) throws Exception<br />
{<br />
// Create a new instance of the application and make the currently<br />
// running thread the application's event dispatch thread.<br />
MyApp theApp = new MyApp(); <br />
theApp.enterEventDispatcher();<br />
}<br />
<br />
<br />
/**<br />
* Creates a new MyApp object<br />
*/<br />
public MyApp()throws Exception<br />
{ <br />
// Check for the presence of the SDCard<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
try{<br />
// create a URI object with te file name and location <br />
String dbLocation = "/SDCard/databases/DBCreator/";<br />
URI uri = URI.create(dbLocation + DB_NAME);<br />
<br />
// open a database connection to that URI<br />
Database db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false));<br />
<br />
// create the table if it does not already exist<br />
Statement statement =<br />
db.createStatement("CREATE TABLE IF NOT EXISTS Student(id INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT, email TEXT, address TEXT)");<br />
statement.prepare();<br />
<br />
//execute the statement<br />
statement.execute();<br />
<br />
// close statement and database<br />
statement.close(); <br />
db.close(); <br />
<br />
}catch(Exception ex ) {<br />
errorDialog(ex.getMessage());<br />
System.exit(0); <br />
}<br />
<br />
}<br />
}<br />
<br />
// Error message dialog<br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
}<br />
<br />
</source><br />
<br />
Now run tha application. Then from the SDCard folder, drag the database file and drop it into your main project, "res" folder.<br />
<br />
===11.3 Add id to Student Class===<br />
Now in our main application project,we need to add id to this class because we are going to preserve our Student objects in database,:<br />
So add a private field and add public getter and setters:<br />
<source lang="java"><br />
<br />
public int getId(){<br />
return this.id;<br />
}<br />
public void setId(int id){<br />
this.id = id;<br />
}<br />
</source><br />
<br />
===11.4 Check for presence of SDCard===<br />
Each time our "Student View" application runs, we have to check for the presence of the SD card, and if it does not exist, we have to show a dialog message.<br />
<br />
Therefore, add the following code to the ViewStudentApp.java class constructor:<br />
<source lang="java"><br />
<br />
public ViewStudentApp() throws Exception {<br />
//This part is from BB Sample application<br />
// Determine if an SDCard is present<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
<br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
// the rest of code goes here<br />
<br />
}<br />
</source><br />
<br />
===11.5 Copy Database File into SDCard===<br />
Now that application knows SDCard is present, It should check if the database file exist, otherwise copy it from the application bundle into SDCard:<br />
<source lang="java"><br />
else<br />
{<br />
String dbLocation = "/SDCard/databases/StudentsList/";<br />
<br />
// Create URI <br />
uri = URI.create(dbLocation + DB_NAME); <br />
<br />
// Open or create a plain text database. This will create the<br />
// directory and file defined by the URI (if they do not already exist).<br />
db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false)); <br />
<br />
// Close the database in case it is blank and we need to write to the file<br />
db.close();<br />
<br />
// Open a connection to the database file <br />
FileConnection fileConnection = (FileConnection)Connector.open("file://" + dbLocation + DB_NAME); <br />
<br />
// If the file is blank, copy the pre-defined database from this<br />
// module to the SDCard.<br />
if(fileConnection.exists() && fileConnection.fileSize() == 0)<br />
{ <br />
readAndWriteDatabaseFile(fileConnection); <br />
} <br />
<br />
// notice that the way we are callling the StudentList constructor is now different.<br />
// Later on you will see that we should modify that class:<br />
_studentList = new StudentList(db, uri);<br />
<br />
// here goes the rest of the constructor code<br />
</source><br />
<br />
Then add the following method (readAndWriteDatabaseFile) to the file that actually reads the database file and puts it into the simulator:<br />
<source lang="java"><br />
public void readAndWriteDatabaseFile(FileConnection fileConnection) throws IOException<br />
{ <br />
OutputStream outputStream = null;<br />
InputStream inputStream = null; <br />
<br />
// Open an input stream to the pre-defined encrypted database bundled<br />
// within this module.<br />
inputStream = getClass().getResourceAsStream("/" + DB_NAME);<br />
<br />
// Open an output stream to the newly created file<br />
outputStream = (OutputStream)fileConnection.openOutputStream(); <br />
<br />
// Read data from the input stream and write the data to the<br />
// output stream. <br />
byte[] data = new byte[256];<br />
int length = 0;<br />
while (-1 != (length = inputStream.read(data)))<br />
{<br />
outputStream.write(data, 0, length); <br />
} <br />
<br />
// Close the connections<br />
if(fileConnection != null)<br />
{<br />
fileConnection.close();<br />
}<br />
if(outputStream != null)<br />
{<br />
outputStream.close();<br />
}<br />
if(inputStream != null)<br />
{<br />
inputStream.close();<br />
} <br />
}<br />
<br />
</source><br />
<br />
===11.6 Create SQLiteManager Class===<br />
<br />
Now we need a class that will be the only class interacting with our database. It will take a Database object and a URI object to open database in the constructor. It will have methods to perform all the queries we need and at the end of each query will close the database. <br/><br />
<br />
So, create a class called: SQLiteManager, with 2 private fields, and a constructor that sets them and then tries to open database:<br />
<source lang="java"><br />
<br />
package cs.ecl.team1.project;<br />
<br />
<br />
<br />
import java.util.Vector;<br />
import net.rim.device.api.database.Cursor;<br />
import net.rim.device.api.database.DataTypeException;<br />
import net.rim.device.api.database.Database;<br />
import net.rim.device.api.database.DatabaseException;<br />
import net.rim.device.api.database.DatabaseFactory;<br />
import net.rim.device.api.database.Row;<br />
import net.rim.device.api.database.Statement;<br />
import net.rim.device.api.io.URI;<br />
import net.rim.device.api.ui.UiApplication;<br />
import net.rim.device.api.ui.component.Dialog;<br />
<br />
public class SQLManager {<br />
<br />
private static Database db;<br />
private URI uri;<br />
<br />
public SQLManager(Database db, URI uri)<br />
{<br />
this.uri = uri;<br />
this.db = db;<br />
openDB();<br />
}<br />
<br />
}<br />
</source><br />
'''11.6.1 Open Database'''<br/><br />
Then we implement the openDB() method:<br />
<source lang="java"><br />
void openDB()<br />
{ <br />
try<br />
{ <br />
this.db = DatabaseFactory.open(uri);<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
} <br />
</source><br />
'''11.6.2 Close Database'''<br/><br />
Then we definitely need a closeDB() method to use later:<br />
<source lang="java"><br />
static void closeDB()<br />
{ <br />
try<br />
{ <br />
db.close();<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
} <br />
</source><br />
And as you noticed above, we are going to need a method called errorDialog():<br />
<source lang="java"><br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
</source><br />
'''11.6.3 Insert New Student'''<br/><br />
The first query we need is a query that enables us add a new Student, so we need to implement a method for that:<br />
<source lang="java"><br />
//ADD STUDENT<br />
Student addStudent(String fName, String lName, String email, String address){<br />
Student student = null;<br />
try<br />
{<br />
<br />
<br />
Statement statement = db.createStatement("INSERT INTO Student VALUES(NULL,?,?,?,?)"); <br />
statement.prepare(); <br />
<br />
statement.bind(1,fName);<br />
statement.bind(2, lName);<br />
statement.bind(3, email);<br />
statement.bind(4, address);<br />
<br />
statement.execute();<br />
statement.close();<br />
<br />
statement = db.createStatement("SELECT id FROM Student WHERE firstName = ? AND lastName = ?");<br />
statement.prepare();<br />
statement.bind(1, fName); <br />
statement.bind(2, lName);<br />
Cursor cursor = statement.getCursor(); <br />
if(cursor.next())<br />
{<br />
Row row = cursor.getRow();<br />
int id = row.getInteger(0); <br />
student = new Student(id, fName, lName, email, address); <br />
} <br />
cursor.close();<br />
statement.close();<br />
}catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
} <br />
catch(DataTypeException dte)<br />
{<br />
errorDialog(dte.toString());<br />
}<br />
<br />
return student;<br />
}<br />
</source><br />
<br />
'''11.6.4 Delete Student'''<br/><br />
Then add a method to delete student by id:<br />
<br />
<source lang="java"><br />
// DELETE STUDENT<br />
<br />
void deleteStudent(int id)<br />
{<br />
try<br />
{<br />
<br />
Statement statement = db.createStatement("DELETE FROM Student WHERE id = ?");<br />
statement.prepare(); <br />
statement.bind(1, id);<br />
statement.execute(); <br />
statement.close();<br />
<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
} <br />
} <br />
</source><br />
'''11.6.5 Update Student'''<br/><br />
And a method to update Student:<br />
<source lang="java"><br />
//UPDATE STUDENT<br />
void updateStudent(int id, String fName, String lName, String email, String address)<br />
{<br />
try<br />
{ <br />
Statement statement = db.createStatement("UPDATE Student SET firstName = ?, lastName= ?, email = ?, address = ? WHERE id = ?");<br />
statement.prepare(); <br />
statement.bind(1, fName);<br />
statement.bind(2, lName);<br />
statement.bind(3, email);<br />
statement.bind(4, address);<br />
statement.bind(5, id); <br />
statement.execute(); <br />
statement.close();<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString()); <br />
} <br />
}<br />
<br />
</source><br />
<br />
'''11.6.6 Select All Students'''<br/><br />
And obviously we will need a method that gets all the students from database and returns a vector of Student, so that we can populate our student list:<br />
<source lang="java"><br />
Vector getStudents(){<br />
Vector students= new Vector();<br />
<br />
try<br />
{ <br />
<br />
Statement statement = db.createStatement("SELECT * FROM Student");<br />
statement.prepare();<br />
Cursor cursor = statement.getCursor();<br />
<br />
// Iterate through the the result set. For each row, add a<br />
// new DirectoryItem object to the vector.<br />
while(cursor.next())<br />
{ <br />
Row row = cursor.getRow();<br />
<br />
int id = row.getInteger(0);<br />
<br />
String fName = row.getString(1);<br />
String lName = row.getString(2);<br />
String email = row.getString(3); <br />
String address = row.getString(4);<br />
<br />
Student student = new Student(id, fName, lName, email, address);<br />
students.addElement(student); <br />
}<br />
statement.close();<br />
cursor.close();<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
catch(DataTypeException dte)<br />
{<br />
errorDialog(dte.toString());<br />
} <br />
<br />
return students; <br />
<br />
}<br />
</source><br />
<br />
===11.7 Modify StudentsList Class to use SQLiteManager===<br />
So far the StudentList class we have, consumes a vector to store students whiche are note preserved. We will modify the methods of this list to use the SQLiteManager and preserve the objects.<br/><br />
Add the following private fields to the StudentList Class:<br />
<source lang="java"><br />
private Database db ;<br />
private URI uri;<br />
</source><br />
Then modify its constructor to take and set thode fields:<br />
<source lang="java"><br />
public StudentList(Database db, URI uri) throws Exception {<br />
super(new StudentListComparator());<br />
this.db = db;<br />
this.uri = uri;<br />
SQLManager sqlManager = new SQLManager(db, uri);<br />
loadFrom(sqlManager.getStudents().elements()); <br />
SQLManager.closeDB();<br />
}<br />
<br />
</source><br />
<br />
'''11.7.1 Load list'''<br/><br />
As noticed above, the constructor then passes those objects to a new SQLiteManager object and gets students from the manager to load the list with. Then it closes the database.<br/><br />
<br />
'''11.7.2 Add Student'''<br/><br />
Now modify the addElement method:<br />
<source lang="java"><br />
/**<br />
* Adds a new element to the list.<br />
* @param element The element to be added.<br />
*/<br />
void addElement(Object element) {<br />
Student student = (Student) element;<br />
SQLManager sqlManager = new SQLManager(db, uri);<br />
sqlManager.addStudent(student.getFirstname(), student.getLastName(), student.getEmail(), student.getAddress());<br />
doAdd(element);<br />
SQLManager.closeDB();<br />
}<br />
<br />
</source><br />
'''11.7.3 Edit Student'''<br/><br />
And editElement method:<br />
<source lang="java"><br />
// added for Update:<br />
void updateElement(Object oldElement, Object newElement){<br />
Student student = (Student) newElement;<br />
SQLManager sqlManager = new SQLManager(db, uri);<br />
sqlManager.updateStudent(student.getId(), student.getFirstname(), student.getLastName(), student.getEmail(), student.getAddress());<br />
doUpdate(oldElement,newElement);<br />
SQLManager.closeDB();<br />
}<br />
<br />
<br />
</source><br />
'''11.7.4 Delete Student'''<br/><br />
<source lang="java"><br />
/**<br />
* Removes element from the list<br />
* @param element<br />
*/<br />
void deleteElement(Object element) {<br />
Student student = (Student)element;<br />
SQLManager sqlManager = new SQLManager(db, uri);<br />
sqlManager.deleteStudent(student.getId());<br />
doRemove(element);<br />
SQLManager.closeDB();<br />
}<br />
<br />
</source><br />
<br />
===11.8 Student View Application in Action===</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62374Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-12T04:28:03Z<p>Ladanzahir: /* 11.7 Modify StudentsList Class to use SQLiteManager */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Add SDCard to Simulator===<br />
To be able to have data preserved on database, first we need to make sure that simulator can simulate SDCard, so that we can run our application with database. For this purpose first create a folder on your file system. Then run the simulator and from the top menu choose: Simulate > Change SD Card... .<br/><br />
Then Mount Directory, and select the folder you just created. Every time you restart the simulator, before running the app you need to make sure that the folder is mounted as SD Card. later on you will see that the database file gets created there.<br/><br />
[[Image: BB_SDCard.png | 350px]]<br/><br />
<br />
===11.2 Create Database File===<br />
We would like to create a database file including out Student Entity, so that we can put it in the project. Then every time the app runs, first it checks if it is the first time run of the app on the device or simulator. If so, the app will copy the file in to the SDCard. Next time that you run the application, it will know that the file is there, so will not override it. <Br/><br />
<br />
For this purpose, create a simple blackberry project with only the application object. We do not need any screen here. call it "DBCreator".<br />
and this will need to only have a class called MyApp.java which extends UIApplication. Here is the code for this class:<br />
<br />
<source lang="java" ><br />
<br />
package mypackage;<br />
<br />
import java.util.Enumeration;<br />
import javax.microedition.io.file.FileSystemRegistry;<br />
import net.rim.device.api.ui.*;<br />
import net.rim.device.api.ui.component.*;<br />
import net.rim.device.api.database.*;<br />
import net.rim.device.api.io.*;<br />
<br />
/**<br />
* This class extends the UiApplication class, providing a<br />
* graphical user interface.<br />
*/<br />
public class MyApp extends UiApplication<br />
{<br />
private static String DB_NAME = "SQLiteStudentList";<br />
<br />
/**<br />
* Entry point for application<br />
* @param args Command line arguments (not used)<br />
*/<br />
public static void main(String[] args) throws Exception<br />
{<br />
// Create a new instance of the application and make the currently<br />
// running thread the application's event dispatch thread.<br />
MyApp theApp = new MyApp(); <br />
theApp.enterEventDispatcher();<br />
}<br />
<br />
<br />
/**<br />
* Creates a new MyApp object<br />
*/<br />
public MyApp()throws Exception<br />
{ <br />
// Check for the presence of the SDCard<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
try{<br />
// create a URI object with te file name and location <br />
String dbLocation = "/SDCard/databases/DBCreator/";<br />
URI uri = URI.create(dbLocation + DB_NAME);<br />
<br />
// open a database connection to that URI<br />
Database db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false));<br />
<br />
// create the table if it does not already exist<br />
Statement statement =<br />
db.createStatement("CREATE TABLE IF NOT EXISTS Student(id INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT, email TEXT, address TEXT)");<br />
statement.prepare();<br />
<br />
//execute the statement<br />
statement.execute();<br />
<br />
// close statement and database<br />
statement.close(); <br />
db.close(); <br />
<br />
}catch(Exception ex ) {<br />
errorDialog(ex.getMessage());<br />
System.exit(0); <br />
}<br />
<br />
}<br />
}<br />
<br />
// Error message dialog<br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
}<br />
<br />
</source><br />
<br />
Now run tha application. Then from the SDCard folder, drag the database file and drop it into your main project, "res" folder.<br />
<br />
===11.3 Add id to Student Class===<br />
Now in our main application project,we need to add id to this class because we are going to preserve our Student objects in database,:<br />
So add a private field and add public getter and setters:<br />
<source lang="java"><br />
<br />
public int getId(){<br />
return this.id;<br />
}<br />
public void setId(int id){<br />
this.id = id;<br />
}<br />
</source><br />
<br />
===11.4 Check for presence of SDCard===<br />
Each time our "Student View" application runs, we have to check for the presence of the SD card, and if it does not exist, we have to show a dialog message.<br />
<br />
Therefore, add the following code to the ViewStudentApp.java class constructor:<br />
<source lang="java"><br />
<br />
public ViewStudentApp() throws Exception {<br />
//This part is from BB Sample application<br />
// Determine if an SDCard is present<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
<br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
// the rest of code goes here<br />
<br />
}<br />
</source><br />
<br />
===11.5 Copy Database File into SDCard===<br />
Now that application knows SDCard is present, It should check if the database file exist, otherwise copy it from the application bundle into SDCard:<br />
<source lang="java"><br />
else<br />
{<br />
String dbLocation = "/SDCard/databases/StudentsList/";<br />
<br />
// Create URI <br />
uri = URI.create(dbLocation + DB_NAME); <br />
<br />
// Open or create a plain text database. This will create the<br />
// directory and file defined by the URI (if they do not already exist).<br />
db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false)); <br />
<br />
// Close the database in case it is blank and we need to write to the file<br />
db.close();<br />
<br />
// Open a connection to the database file <br />
FileConnection fileConnection = (FileConnection)Connector.open("file://" + dbLocation + DB_NAME); <br />
<br />
// If the file is blank, copy the pre-defined database from this<br />
// module to the SDCard.<br />
if(fileConnection.exists() && fileConnection.fileSize() == 0)<br />
{ <br />
readAndWriteDatabaseFile(fileConnection); <br />
} <br />
// here goes the rest of the constructor code<br />
_studentList = new StudentList(db, uri);<br />
</source><br />
<br />
Then add the following method (readAndWriteDatabaseFile) to the file that actually reads the database file and puts it into the simulator:<br />
<source lang="java"><br />
public void readAndWriteDatabaseFile(FileConnection fileConnection) throws IOException<br />
{ <br />
OutputStream outputStream = null;<br />
InputStream inputStream = null; <br />
<br />
// Open an input stream to the pre-defined encrypted database bundled<br />
// within this module.<br />
inputStream = getClass().getResourceAsStream("/" + DB_NAME);<br />
<br />
// Open an output stream to the newly created file<br />
outputStream = (OutputStream)fileConnection.openOutputStream(); <br />
<br />
// Read data from the input stream and write the data to the<br />
// output stream. <br />
byte[] data = new byte[256];<br />
int length = 0;<br />
while (-1 != (length = inputStream.read(data)))<br />
{<br />
outputStream.write(data, 0, length); <br />
} <br />
<br />
// Close the connections<br />
if(fileConnection != null)<br />
{<br />
fileConnection.close();<br />
}<br />
if(outputStream != null)<br />
{<br />
outputStream.close();<br />
}<br />
if(inputStream != null)<br />
{<br />
inputStream.close();<br />
} <br />
}<br />
<br />
</source><br />
<br />
===11.6 Create SQLiteManager Class===<br />
<br />
Now we need a class that will be the only class interacting with our database. It will take a Database object and a URI object to open database in the constructor. It will have methods to perform all the queries we need and at the end of each query will close the database. <br/><br />
<br />
So, create a class called: SQLiteManager, with 2 private fields, and a constructor that sets them and then tries to open database:<br />
<source lang="java"><br />
<br />
package cs.ecl.team1.project;<br />
<br />
<br />
<br />
import java.util.Vector;<br />
import net.rim.device.api.database.Cursor;<br />
import net.rim.device.api.database.DataTypeException;<br />
import net.rim.device.api.database.Database;<br />
import net.rim.device.api.database.DatabaseException;<br />
import net.rim.device.api.database.DatabaseFactory;<br />
import net.rim.device.api.database.Row;<br />
import net.rim.device.api.database.Statement;<br />
import net.rim.device.api.io.URI;<br />
import net.rim.device.api.ui.UiApplication;<br />
import net.rim.device.api.ui.component.Dialog;<br />
<br />
public class SQLManager {<br />
<br />
private static Database db;<br />
private URI uri;<br />
<br />
public SQLManager(Database db, URI uri)<br />
{<br />
this.uri = uri;<br />
this.db = db;<br />
openDB();<br />
}<br />
<br />
}<br />
</source><br />
'''11.6.1 Open Database'''<br/><br />
Then we implement the openDB() method:<br />
<source lang="java"><br />
void openDB()<br />
{ <br />
try<br />
{ <br />
this.db = DatabaseFactory.open(uri);<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
} <br />
</source><br />
'''11.6.2 Close Database'''<br/><br />
Then we definitely need a closeDB() method to use later:<br />
<source lang="java"><br />
static void closeDB()<br />
{ <br />
try<br />
{ <br />
db.close();<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
} <br />
</source><br />
And as you noticed above, we are going to need a method called errorDialog():<br />
<source lang="java"><br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
</source><br />
'''11.6.3 Insert New Student'''<br/><br />
The first query we need is a query that enables us add a new Student, so we need to implement a method for that:<br />
<source lang="java"><br />
//ADD STUDENT<br />
Student addStudent(String fName, String lName, String email, String address){<br />
Student student = null;<br />
try<br />
{<br />
<br />
<br />
Statement statement = db.createStatement("INSERT INTO Student VALUES(NULL,?,?,?,?)"); <br />
statement.prepare(); <br />
<br />
statement.bind(1,fName);<br />
statement.bind(2, lName);<br />
statement.bind(3, email);<br />
statement.bind(4, address);<br />
<br />
statement.execute();<br />
statement.close();<br />
<br />
statement = db.createStatement("SELECT id FROM Student WHERE firstName = ? AND lastName = ?");<br />
statement.prepare();<br />
statement.bind(1, fName); <br />
statement.bind(2, lName);<br />
Cursor cursor = statement.getCursor(); <br />
if(cursor.next())<br />
{<br />
Row row = cursor.getRow();<br />
int id = row.getInteger(0); <br />
student = new Student(id, fName, lName, email, address); <br />
} <br />
cursor.close();<br />
statement.close();<br />
}catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
} <br />
catch(DataTypeException dte)<br />
{<br />
errorDialog(dte.toString());<br />
}<br />
<br />
return student;<br />
}<br />
</source><br />
<br />
'''11.6.4 Delete Student'''<br/><br />
Then add a method to delete student by id:<br />
<br />
<source lang="java"><br />
// DELETE STUDENT<br />
<br />
void deleteStudent(int id)<br />
{<br />
try<br />
{<br />
<br />
Statement statement = db.createStatement("DELETE FROM Student WHERE id = ?");<br />
statement.prepare(); <br />
statement.bind(1, id);<br />
statement.execute(); <br />
statement.close();<br />
<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
} <br />
} <br />
</source><br />
'''11.6.5 Update Student'''<br/><br />
And a method to update Student:<br />
<source lang="java"><br />
//UPDATE STUDENT<br />
void updateStudent(int id, String fName, String lName, String email, String address)<br />
{<br />
try<br />
{ <br />
Statement statement = db.createStatement("UPDATE Student SET firstName = ?, lastName= ?, email = ?, address = ? WHERE id = ?");<br />
statement.prepare(); <br />
statement.bind(1, fName);<br />
statement.bind(2, lName);<br />
statement.bind(3, email);<br />
statement.bind(4, address);<br />
statement.bind(5, id); <br />
statement.execute(); <br />
statement.close();<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString()); <br />
} <br />
}<br />
<br />
</source><br />
<br />
'''11.6.6 Select All Students'''<br/><br />
And obviously we will need a method that gets all the students from database and returns a vector of Student, so that we can populate our student list:<br />
<source lang="java"><br />
Vector getStudents(){<br />
Vector students= new Vector();<br />
<br />
try<br />
{ <br />
<br />
Statement statement = db.createStatement("SELECT * FROM Student");<br />
statement.prepare();<br />
Cursor cursor = statement.getCursor();<br />
<br />
// Iterate through the the result set. For each row, add a<br />
// new DirectoryItem object to the vector.<br />
while(cursor.next())<br />
{ <br />
Row row = cursor.getRow();<br />
<br />
int id = row.getInteger(0);<br />
<br />
String fName = row.getString(1);<br />
String lName = row.getString(2);<br />
String email = row.getString(3); <br />
String address = row.getString(4);<br />
<br />
Student student = new Student(id, fName, lName, email, address);<br />
students.addElement(student); <br />
}<br />
statement.close();<br />
cursor.close();<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
catch(DataTypeException dte)<br />
{<br />
errorDialog(dte.toString());<br />
} <br />
<br />
return students; <br />
<br />
}<br />
</source><br />
<br />
===11.7 Modify StudentsList Class to use SQLiteManager===<br />
So far the StudentList class we have, consumes a vector to store students whiche are note preserved. We will modify the methods of this list to use the SQLiteManager and preserve the objects.<br/><br />
Add the following private fields to the StudentList Class:<br />
<source lang="java"><br />
private Database db ;<br />
private URI uri;<br />
</source><br />
Then modify its constructor to take and set thode fields:<br />
<source lang="java"><br />
public StudentList(Database db, URI uri) throws Exception {<br />
super(new StudentListComparator());<br />
this.db = db;<br />
this.uri = uri;<br />
SQLManager sqlManager = new SQLManager(db, uri);<br />
loadFrom(sqlManager.getStudents().elements()); <br />
SQLManager.closeDB();<br />
}<br />
<br />
</source><br />
<br />
'''11.7.1 Load list'''<br/><br />
As noticed above, the constructor then passes those objects to a new SQLiteManager object and gets students from the manager to load the list with. Then it closes the database.<br/><br />
<br />
'''11.7.2 Add Student'''<br/><br />
Now modify the addElement method:<br />
<source lang="java"><br />
/**<br />
* Adds a new element to the list.<br />
* @param element The element to be added.<br />
*/<br />
void addElement(Object element) {<br />
Student student = (Student) element;<br />
SQLManager sqlManager = new SQLManager(db, uri);<br />
sqlManager.addStudent(student.getFirstname(), student.getLastName(), student.getEmail(), student.getAddress());<br />
doAdd(element);<br />
SQLManager.closeDB();<br />
}<br />
<br />
</source><br />
'''11.7.3 Edit Student'''<br/><br />
And editElement method:<br />
<source lang="java"><br />
// added for Update:<br />
void updateElement(Object oldElement, Object newElement){<br />
Student student = (Student) newElement;<br />
SQLManager sqlManager = new SQLManager(db, uri);<br />
sqlManager.updateStudent(student.getId(), student.getFirstname(), student.getLastName(), student.getEmail(), student.getAddress());<br />
doUpdate(oldElement,newElement);<br />
SQLManager.closeDB();<br />
}<br />
<br />
<br />
</source><br />
'''11.7.4 Delete Student'''<br/><br />
<source lang="java"><br />
/**<br />
* Removes element from the list<br />
* @param element<br />
*/<br />
void deleteElement(Object element) {<br />
Student student = (Student)element;<br />
SQLManager sqlManager = new SQLManager(db, uri);<br />
sqlManager.deleteStudent(student.getId());<br />
doRemove(element);<br />
SQLManager.closeDB();<br />
}<br />
<br />
</source><br />
<br />
===11.8 Student View Application in Action===</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62373Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-12T04:27:20Z<p>Ladanzahir: /* 11.7 Modify StudentsList Class to use SQLiteManager */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Add SDCard to Simulator===<br />
To be able to have data preserved on database, first we need to make sure that simulator can simulate SDCard, so that we can run our application with database. For this purpose first create a folder on your file system. Then run the simulator and from the top menu choose: Simulate > Change SD Card... .<br/><br />
Then Mount Directory, and select the folder you just created. Every time you restart the simulator, before running the app you need to make sure that the folder is mounted as SD Card. later on you will see that the database file gets created there.<br/><br />
[[Image: BB_SDCard.png | 350px]]<br/><br />
<br />
===11.2 Create Database File===<br />
We would like to create a database file including out Student Entity, so that we can put it in the project. Then every time the app runs, first it checks if it is the first time run of the app on the device or simulator. If so, the app will copy the file in to the SDCard. Next time that you run the application, it will know that the file is there, so will not override it. <Br/><br />
<br />
For this purpose, create a simple blackberry project with only the application object. We do not need any screen here. call it "DBCreator".<br />
and this will need to only have a class called MyApp.java which extends UIApplication. Here is the code for this class:<br />
<br />
<source lang="java" ><br />
<br />
package mypackage;<br />
<br />
import java.util.Enumeration;<br />
import javax.microedition.io.file.FileSystemRegistry;<br />
import net.rim.device.api.ui.*;<br />
import net.rim.device.api.ui.component.*;<br />
import net.rim.device.api.database.*;<br />
import net.rim.device.api.io.*;<br />
<br />
/**<br />
* This class extends the UiApplication class, providing a<br />
* graphical user interface.<br />
*/<br />
public class MyApp extends UiApplication<br />
{<br />
private static String DB_NAME = "SQLiteStudentList";<br />
<br />
/**<br />
* Entry point for application<br />
* @param args Command line arguments (not used)<br />
*/<br />
public static void main(String[] args) throws Exception<br />
{<br />
// Create a new instance of the application and make the currently<br />
// running thread the application's event dispatch thread.<br />
MyApp theApp = new MyApp(); <br />
theApp.enterEventDispatcher();<br />
}<br />
<br />
<br />
/**<br />
* Creates a new MyApp object<br />
*/<br />
public MyApp()throws Exception<br />
{ <br />
// Check for the presence of the SDCard<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
try{<br />
// create a URI object with te file name and location <br />
String dbLocation = "/SDCard/databases/DBCreator/";<br />
URI uri = URI.create(dbLocation + DB_NAME);<br />
<br />
// open a database connection to that URI<br />
Database db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false));<br />
<br />
// create the table if it does not already exist<br />
Statement statement =<br />
db.createStatement("CREATE TABLE IF NOT EXISTS Student(id INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT, email TEXT, address TEXT)");<br />
statement.prepare();<br />
<br />
//execute the statement<br />
statement.execute();<br />
<br />
// close statement and database<br />
statement.close(); <br />
db.close(); <br />
<br />
}catch(Exception ex ) {<br />
errorDialog(ex.getMessage());<br />
System.exit(0); <br />
}<br />
<br />
}<br />
}<br />
<br />
// Error message dialog<br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
}<br />
<br />
</source><br />
<br />
Now run tha application. Then from the SDCard folder, drag the database file and drop it into your main project, "res" folder.<br />
<br />
===11.3 Add id to Student Class===<br />
Now in our main application project,we need to add id to this class because we are going to preserve our Student objects in database,:<br />
So add a private field and add public getter and setters:<br />
<source lang="java"><br />
<br />
public int getId(){<br />
return this.id;<br />
}<br />
public void setId(int id){<br />
this.id = id;<br />
}<br />
</source><br />
<br />
===11.4 Check for presence of SDCard===<br />
Each time our "Student View" application runs, we have to check for the presence of the SD card, and if it does not exist, we have to show a dialog message.<br />
<br />
Therefore, add the following code to the ViewStudentApp.java class constructor:<br />
<source lang="java"><br />
<br />
public ViewStudentApp() throws Exception {<br />
//This part is from BB Sample application<br />
// Determine if an SDCard is present<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
<br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
// the rest of code goes here<br />
<br />
}<br />
</source><br />
<br />
===11.5 Copy Database File into SDCard===<br />
Now that application knows SDCard is present, It should check if the database file exist, otherwise copy it from the application bundle into SDCard:<br />
<source lang="java"><br />
else<br />
{<br />
String dbLocation = "/SDCard/databases/StudentsList/";<br />
<br />
// Create URI <br />
uri = URI.create(dbLocation + DB_NAME); <br />
<br />
// Open or create a plain text database. This will create the<br />
// directory and file defined by the URI (if they do not already exist).<br />
db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false)); <br />
<br />
// Close the database in case it is blank and we need to write to the file<br />
db.close();<br />
<br />
// Open a connection to the database file <br />
FileConnection fileConnection = (FileConnection)Connector.open("file://" + dbLocation + DB_NAME); <br />
<br />
// If the file is blank, copy the pre-defined database from this<br />
// module to the SDCard.<br />
if(fileConnection.exists() && fileConnection.fileSize() == 0)<br />
{ <br />
readAndWriteDatabaseFile(fileConnection); <br />
} <br />
// here goes the rest of the constructor code<br />
_studentList = new StudentList(db, uri);<br />
</source><br />
<br />
Then add the following method (readAndWriteDatabaseFile) to the file that actually reads the database file and puts it into the simulator:<br />
<source lang="java"><br />
public void readAndWriteDatabaseFile(FileConnection fileConnection) throws IOException<br />
{ <br />
OutputStream outputStream = null;<br />
InputStream inputStream = null; <br />
<br />
// Open an input stream to the pre-defined encrypted database bundled<br />
// within this module.<br />
inputStream = getClass().getResourceAsStream("/" + DB_NAME);<br />
<br />
// Open an output stream to the newly created file<br />
outputStream = (OutputStream)fileConnection.openOutputStream(); <br />
<br />
// Read data from the input stream and write the data to the<br />
// output stream. <br />
byte[] data = new byte[256];<br />
int length = 0;<br />
while (-1 != (length = inputStream.read(data)))<br />
{<br />
outputStream.write(data, 0, length); <br />
} <br />
<br />
// Close the connections<br />
if(fileConnection != null)<br />
{<br />
fileConnection.close();<br />
}<br />
if(outputStream != null)<br />
{<br />
outputStream.close();<br />
}<br />
if(inputStream != null)<br />
{<br />
inputStream.close();<br />
} <br />
}<br />
<br />
</source><br />
<br />
===11.6 Create SQLiteManager Class===<br />
<br />
Now we need a class that will be the only class interacting with our database. It will take a Database object and a URI object to open database in the constructor. It will have methods to perform all the queries we need and at the end of each query will close the database. <br/><br />
<br />
So, create a class called: SQLiteManager, with 2 private fields, and a constructor that sets them and then tries to open database:<br />
<source lang="java"><br />
<br />
package cs.ecl.team1.project;<br />
<br />
<br />
<br />
import java.util.Vector;<br />
import net.rim.device.api.database.Cursor;<br />
import net.rim.device.api.database.DataTypeException;<br />
import net.rim.device.api.database.Database;<br />
import net.rim.device.api.database.DatabaseException;<br />
import net.rim.device.api.database.DatabaseFactory;<br />
import net.rim.device.api.database.Row;<br />
import net.rim.device.api.database.Statement;<br />
import net.rim.device.api.io.URI;<br />
import net.rim.device.api.ui.UiApplication;<br />
import net.rim.device.api.ui.component.Dialog;<br />
<br />
public class SQLManager {<br />
<br />
private static Database db;<br />
private URI uri;<br />
<br />
public SQLManager(Database db, URI uri)<br />
{<br />
this.uri = uri;<br />
this.db = db;<br />
openDB();<br />
}<br />
<br />
}<br />
</source><br />
'''11.6.1 Open Database'''<br/><br />
Then we implement the openDB() method:<br />
<source lang="java"><br />
void openDB()<br />
{ <br />
try<br />
{ <br />
this.db = DatabaseFactory.open(uri);<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
} <br />
</source><br />
'''11.6.2 Close Database'''<br/><br />
Then we definitely need a closeDB() method to use later:<br />
<source lang="java"><br />
static void closeDB()<br />
{ <br />
try<br />
{ <br />
db.close();<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
} <br />
</source><br />
And as you noticed above, we are going to need a method called errorDialog():<br />
<source lang="java"><br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
</source><br />
'''11.6.3 Insert New Student'''<br/><br />
The first query we need is a query that enables us add a new Student, so we need to implement a method for that:<br />
<source lang="java"><br />
//ADD STUDENT<br />
Student addStudent(String fName, String lName, String email, String address){<br />
Student student = null;<br />
try<br />
{<br />
<br />
<br />
Statement statement = db.createStatement("INSERT INTO Student VALUES(NULL,?,?,?,?)"); <br />
statement.prepare(); <br />
<br />
statement.bind(1,fName);<br />
statement.bind(2, lName);<br />
statement.bind(3, email);<br />
statement.bind(4, address);<br />
<br />
statement.execute();<br />
statement.close();<br />
<br />
statement = db.createStatement("SELECT id FROM Student WHERE firstName = ? AND lastName = ?");<br />
statement.prepare();<br />
statement.bind(1, fName); <br />
statement.bind(2, lName);<br />
Cursor cursor = statement.getCursor(); <br />
if(cursor.next())<br />
{<br />
Row row = cursor.getRow();<br />
int id = row.getInteger(0); <br />
student = new Student(id, fName, lName, email, address); <br />
} <br />
cursor.close();<br />
statement.close();<br />
}catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
} <br />
catch(DataTypeException dte)<br />
{<br />
errorDialog(dte.toString());<br />
}<br />
<br />
return student;<br />
}<br />
</source><br />
<br />
'''11.6.4 Delete Student'''<br/><br />
Then add a method to delete student by id:<br />
<br />
<source lang="java"><br />
// DELETE STUDENT<br />
<br />
void deleteStudent(int id)<br />
{<br />
try<br />
{<br />
<br />
Statement statement = db.createStatement("DELETE FROM Student WHERE id = ?");<br />
statement.prepare(); <br />
statement.bind(1, id);<br />
statement.execute(); <br />
statement.close();<br />
<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
} <br />
} <br />
</source><br />
'''11.6.5 Update Student'''<br/><br />
And a method to update Student:<br />
<source lang="java"><br />
//UPDATE STUDENT<br />
void updateStudent(int id, String fName, String lName, String email, String address)<br />
{<br />
try<br />
{ <br />
Statement statement = db.createStatement("UPDATE Student SET firstName = ?, lastName= ?, email = ?, address = ? WHERE id = ?");<br />
statement.prepare(); <br />
statement.bind(1, fName);<br />
statement.bind(2, lName);<br />
statement.bind(3, email);<br />
statement.bind(4, address);<br />
statement.bind(5, id); <br />
statement.execute(); <br />
statement.close();<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString()); <br />
} <br />
}<br />
<br />
</source><br />
<br />
'''11.6.6 Select All Students'''<br/><br />
And obviously we will need a method that gets all the students from database and returns a vector of Student, so that we can populate our student list:<br />
<source lang="java"><br />
Vector getStudents(){<br />
Vector students= new Vector();<br />
<br />
try<br />
{ <br />
<br />
Statement statement = db.createStatement("SELECT * FROM Student");<br />
statement.prepare();<br />
Cursor cursor = statement.getCursor();<br />
<br />
// Iterate through the the result set. For each row, add a<br />
// new DirectoryItem object to the vector.<br />
while(cursor.next())<br />
{ <br />
Row row = cursor.getRow();<br />
<br />
int id = row.getInteger(0);<br />
<br />
String fName = row.getString(1);<br />
String lName = row.getString(2);<br />
String email = row.getString(3); <br />
String address = row.getString(4);<br />
<br />
Student student = new Student(id, fName, lName, email, address);<br />
students.addElement(student); <br />
}<br />
statement.close();<br />
cursor.close();<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
catch(DataTypeException dte)<br />
{<br />
errorDialog(dte.toString());<br />
} <br />
<br />
return students; <br />
<br />
}<br />
</source><br />
<br />
===11.7 Modify StudentsList Class to use SQLiteManager===<br />
So far the StudentList class we have, consumes a vector to store students whiche are note preserved. We will modify the methods of this list to use the SQLiteManager and preserve the objects.<br/><br />
Add the following private fields to the StudentList Class:<br />
<source lang="java"><br />
private Database db ;<br />
private URI uri;<br />
</source><br />
Then modify its constructor to take and set thode fields:<br />
<source lang="java"><br />
public StudentList(Database db, URI uri) throws Exception {<br />
super(new StudentListComparator());<br />
this.db = db;<br />
this.uri = uri;<br />
SQLManager sqlManager = new SQLManager(db, uri);<br />
loadFrom(sqlManager.getStudents().elements()); <br />
SQLManager.closeDB();<br />
}<br />
<br />
</source><br />
<br />
11.7.1 Load list<br/><br />
As noticed above, the constructor then passes those objects to a new SQLiteManager object and gets students from the manager to load the list with. Then it closes the database.<br/><br />
<br />
11.7.2 Add Student<br/><br />
Now modify the addElement method:<br />
<source lang="java"><br />
/**<br />
* Adds a new element to the list.<br />
* @param element The element to be added.<br />
*/<br />
void addElement(Object element) {<br />
Student student = (Student) element;<br />
SQLManager sqlManager = new SQLManager(db, uri);<br />
sqlManager.addStudent(student.getFirstname(), student.getLastName(), student.getEmail(), student.getAddress());<br />
doAdd(element);<br />
SQLManager.closeDB();<br />
}<br />
<br />
</source><br />
11.7.3 Edit Student<br/><br />
And editElement method:<br />
<source lang="java"><br />
// added for Update:<br />
void updateElement(Object oldElement, Object newElement){<br />
Student student = (Student) newElement;<br />
SQLManager sqlManager = new SQLManager(db, uri);<br />
sqlManager.updateStudent(student.getId(), student.getFirstname(), student.getLastName(), student.getEmail(), student.getAddress());<br />
doUpdate(oldElement,newElement);<br />
SQLManager.closeDB();<br />
}<br />
<br />
<br />
</source><br />
11.7.4 Delete Student<br/><br />
<source lang="java"><br />
/**<br />
* Removes element from the list<br />
* @param element<br />
*/<br />
void deleteElement(Object element) {<br />
Student student = (Student)element;<br />
SQLManager sqlManager = new SQLManager(db, uri);<br />
sqlManager.deleteStudent(student.getId());<br />
doRemove(element);<br />
SQLManager.closeDB();<br />
}<br />
<br />
</source><br />
<br />
===11.8 Student View Application in Action===</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62372Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-12T04:26:08Z<p>Ladanzahir: /* 11.7 Modify StudentsList Class to use SQLiteManager */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Add SDCard to Simulator===<br />
To be able to have data preserved on database, first we need to make sure that simulator can simulate SDCard, so that we can run our application with database. For this purpose first create a folder on your file system. Then run the simulator and from the top menu choose: Simulate > Change SD Card... .<br/><br />
Then Mount Directory, and select the folder you just created. Every time you restart the simulator, before running the app you need to make sure that the folder is mounted as SD Card. later on you will see that the database file gets created there.<br/><br />
[[Image: BB_SDCard.png | 350px]]<br/><br />
<br />
===11.2 Create Database File===<br />
We would like to create a database file including out Student Entity, so that we can put it in the project. Then every time the app runs, first it checks if it is the first time run of the app on the device or simulator. If so, the app will copy the file in to the SDCard. Next time that you run the application, it will know that the file is there, so will not override it. <Br/><br />
<br />
For this purpose, create a simple blackberry project with only the application object. We do not need any screen here. call it "DBCreator".<br />
and this will need to only have a class called MyApp.java which extends UIApplication. Here is the code for this class:<br />
<br />
<source lang="java" ><br />
<br />
package mypackage;<br />
<br />
import java.util.Enumeration;<br />
import javax.microedition.io.file.FileSystemRegistry;<br />
import net.rim.device.api.ui.*;<br />
import net.rim.device.api.ui.component.*;<br />
import net.rim.device.api.database.*;<br />
import net.rim.device.api.io.*;<br />
<br />
/**<br />
* This class extends the UiApplication class, providing a<br />
* graphical user interface.<br />
*/<br />
public class MyApp extends UiApplication<br />
{<br />
private static String DB_NAME = "SQLiteStudentList";<br />
<br />
/**<br />
* Entry point for application<br />
* @param args Command line arguments (not used)<br />
*/<br />
public static void main(String[] args) throws Exception<br />
{<br />
// Create a new instance of the application and make the currently<br />
// running thread the application's event dispatch thread.<br />
MyApp theApp = new MyApp(); <br />
theApp.enterEventDispatcher();<br />
}<br />
<br />
<br />
/**<br />
* Creates a new MyApp object<br />
*/<br />
public MyApp()throws Exception<br />
{ <br />
// Check for the presence of the SDCard<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
try{<br />
// create a URI object with te file name and location <br />
String dbLocation = "/SDCard/databases/DBCreator/";<br />
URI uri = URI.create(dbLocation + DB_NAME);<br />
<br />
// open a database connection to that URI<br />
Database db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false));<br />
<br />
// create the table if it does not already exist<br />
Statement statement =<br />
db.createStatement("CREATE TABLE IF NOT EXISTS Student(id INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT, email TEXT, address TEXT)");<br />
statement.prepare();<br />
<br />
//execute the statement<br />
statement.execute();<br />
<br />
// close statement and database<br />
statement.close(); <br />
db.close(); <br />
<br />
}catch(Exception ex ) {<br />
errorDialog(ex.getMessage());<br />
System.exit(0); <br />
}<br />
<br />
}<br />
}<br />
<br />
// Error message dialog<br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
}<br />
<br />
</source><br />
<br />
Now run tha application. Then from the SDCard folder, drag the database file and drop it into your main project, "res" folder.<br />
<br />
===11.3 Add id to Student Class===<br />
Now in our main application project,we need to add id to this class because we are going to preserve our Student objects in database,:<br />
So add a private field and add public getter and setters:<br />
<source lang="java"><br />
<br />
public int getId(){<br />
return this.id;<br />
}<br />
public void setId(int id){<br />
this.id = id;<br />
}<br />
</source><br />
<br />
===11.4 Check for presence of SDCard===<br />
Each time our "Student View" application runs, we have to check for the presence of the SD card, and if it does not exist, we have to show a dialog message.<br />
<br />
Therefore, add the following code to the ViewStudentApp.java class constructor:<br />
<source lang="java"><br />
<br />
public ViewStudentApp() throws Exception {<br />
//This part is from BB Sample application<br />
// Determine if an SDCard is present<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
<br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
// the rest of code goes here<br />
<br />
}<br />
</source><br />
<br />
===11.5 Copy Database File into SDCard===<br />
Now that application knows SDCard is present, It should check if the database file exist, otherwise copy it from the application bundle into SDCard:<br />
<source lang="java"><br />
else<br />
{<br />
String dbLocation = "/SDCard/databases/StudentsList/";<br />
<br />
// Create URI <br />
uri = URI.create(dbLocation + DB_NAME); <br />
<br />
// Open or create a plain text database. This will create the<br />
// directory and file defined by the URI (if they do not already exist).<br />
db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false)); <br />
<br />
// Close the database in case it is blank and we need to write to the file<br />
db.close();<br />
<br />
// Open a connection to the database file <br />
FileConnection fileConnection = (FileConnection)Connector.open("file://" + dbLocation + DB_NAME); <br />
<br />
// If the file is blank, copy the pre-defined database from this<br />
// module to the SDCard.<br />
if(fileConnection.exists() && fileConnection.fileSize() == 0)<br />
{ <br />
readAndWriteDatabaseFile(fileConnection); <br />
} <br />
// here goes the rest of the constructor code<br />
_studentList = new StudentList(db, uri);<br />
</source><br />
<br />
Then add the following method (readAndWriteDatabaseFile) to the file that actually reads the database file and puts it into the simulator:<br />
<source lang="java"><br />
public void readAndWriteDatabaseFile(FileConnection fileConnection) throws IOException<br />
{ <br />
OutputStream outputStream = null;<br />
InputStream inputStream = null; <br />
<br />
// Open an input stream to the pre-defined encrypted database bundled<br />
// within this module.<br />
inputStream = getClass().getResourceAsStream("/" + DB_NAME);<br />
<br />
// Open an output stream to the newly created file<br />
outputStream = (OutputStream)fileConnection.openOutputStream(); <br />
<br />
// Read data from the input stream and write the data to the<br />
// output stream. <br />
byte[] data = new byte[256];<br />
int length = 0;<br />
while (-1 != (length = inputStream.read(data)))<br />
{<br />
outputStream.write(data, 0, length); <br />
} <br />
<br />
// Close the connections<br />
if(fileConnection != null)<br />
{<br />
fileConnection.close();<br />
}<br />
if(outputStream != null)<br />
{<br />
outputStream.close();<br />
}<br />
if(inputStream != null)<br />
{<br />
inputStream.close();<br />
} <br />
}<br />
<br />
</source><br />
<br />
===11.6 Create SQLiteManager Class===<br />
<br />
Now we need a class that will be the only class interacting with our database. It will take a Database object and a URI object to open database in the constructor. It will have methods to perform all the queries we need and at the end of each query will close the database. <br/><br />
<br />
So, create a class called: SQLiteManager, with 2 private fields, and a constructor that sets them and then tries to open database:<br />
<source lang="java"><br />
<br />
package cs.ecl.team1.project;<br />
<br />
<br />
<br />
import java.util.Vector;<br />
import net.rim.device.api.database.Cursor;<br />
import net.rim.device.api.database.DataTypeException;<br />
import net.rim.device.api.database.Database;<br />
import net.rim.device.api.database.DatabaseException;<br />
import net.rim.device.api.database.DatabaseFactory;<br />
import net.rim.device.api.database.Row;<br />
import net.rim.device.api.database.Statement;<br />
import net.rim.device.api.io.URI;<br />
import net.rim.device.api.ui.UiApplication;<br />
import net.rim.device.api.ui.component.Dialog;<br />
<br />
public class SQLManager {<br />
<br />
private static Database db;<br />
private URI uri;<br />
<br />
public SQLManager(Database db, URI uri)<br />
{<br />
this.uri = uri;<br />
this.db = db;<br />
openDB();<br />
}<br />
<br />
}<br />
</source><br />
'''11.6.1 Open Database'''<br/><br />
Then we implement the openDB() method:<br />
<source lang="java"><br />
void openDB()<br />
{ <br />
try<br />
{ <br />
this.db = DatabaseFactory.open(uri);<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
} <br />
</source><br />
'''11.6.2 Close Database'''<br/><br />
Then we definitely need a closeDB() method to use later:<br />
<source lang="java"><br />
static void closeDB()<br />
{ <br />
try<br />
{ <br />
db.close();<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
} <br />
</source><br />
And as you noticed above, we are going to need a method called errorDialog():<br />
<source lang="java"><br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
</source><br />
'''11.6.3 Insert New Student'''<br/><br />
The first query we need is a query that enables us add a new Student, so we need to implement a method for that:<br />
<source lang="java"><br />
//ADD STUDENT<br />
Student addStudent(String fName, String lName, String email, String address){<br />
Student student = null;<br />
try<br />
{<br />
<br />
<br />
Statement statement = db.createStatement("INSERT INTO Student VALUES(NULL,?,?,?,?)"); <br />
statement.prepare(); <br />
<br />
statement.bind(1,fName);<br />
statement.bind(2, lName);<br />
statement.bind(3, email);<br />
statement.bind(4, address);<br />
<br />
statement.execute();<br />
statement.close();<br />
<br />
statement = db.createStatement("SELECT id FROM Student WHERE firstName = ? AND lastName = ?");<br />
statement.prepare();<br />
statement.bind(1, fName); <br />
statement.bind(2, lName);<br />
Cursor cursor = statement.getCursor(); <br />
if(cursor.next())<br />
{<br />
Row row = cursor.getRow();<br />
int id = row.getInteger(0); <br />
student = new Student(id, fName, lName, email, address); <br />
} <br />
cursor.close();<br />
statement.close();<br />
}catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
} <br />
catch(DataTypeException dte)<br />
{<br />
errorDialog(dte.toString());<br />
}<br />
<br />
return student;<br />
}<br />
</source><br />
<br />
'''11.6.4 Delete Student'''<br/><br />
Then add a method to delete student by id:<br />
<br />
<source lang="java"><br />
// DELETE STUDENT<br />
<br />
void deleteStudent(int id)<br />
{<br />
try<br />
{<br />
<br />
Statement statement = db.createStatement("DELETE FROM Student WHERE id = ?");<br />
statement.prepare(); <br />
statement.bind(1, id);<br />
statement.execute(); <br />
statement.close();<br />
<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
} <br />
} <br />
</source><br />
'''11.6.5 Update Student'''<br/><br />
And a method to update Student:<br />
<source lang="java"><br />
//UPDATE STUDENT<br />
void updateStudent(int id, String fName, String lName, String email, String address)<br />
{<br />
try<br />
{ <br />
Statement statement = db.createStatement("UPDATE Student SET firstName = ?, lastName= ?, email = ?, address = ? WHERE id = ?");<br />
statement.prepare(); <br />
statement.bind(1, fName);<br />
statement.bind(2, lName);<br />
statement.bind(3, email);<br />
statement.bind(4, address);<br />
statement.bind(5, id); <br />
statement.execute(); <br />
statement.close();<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString()); <br />
} <br />
}<br />
<br />
</source><br />
<br />
'''11.6.6 Select All Students'''<br/><br />
And obviously we will need a method that gets all the students from database and returns a vector of Student, so that we can populate our student list:<br />
<source lang="java"><br />
Vector getStudents(){<br />
Vector students= new Vector();<br />
<br />
try<br />
{ <br />
<br />
Statement statement = db.createStatement("SELECT * FROM Student");<br />
statement.prepare();<br />
Cursor cursor = statement.getCursor();<br />
<br />
// Iterate through the the result set. For each row, add a<br />
// new DirectoryItem object to the vector.<br />
while(cursor.next())<br />
{ <br />
Row row = cursor.getRow();<br />
<br />
int id = row.getInteger(0);<br />
<br />
String fName = row.getString(1);<br />
String lName = row.getString(2);<br />
String email = row.getString(3); <br />
String address = row.getString(4);<br />
<br />
Student student = new Student(id, fName, lName, email, address);<br />
students.addElement(student); <br />
}<br />
statement.close();<br />
cursor.close();<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
catch(DataTypeException dte)<br />
{<br />
errorDialog(dte.toString());<br />
} <br />
<br />
return students; <br />
<br />
}<br />
</source><br />
<br />
===11.7 Modify StudentsList Class to use SQLiteManager===<br />
So far the StudentList class we have, consumes a vector to store students whiche are note preserved. We will modify the methods of this list to use the SQLiteManager and preserve the objects.<br/><br />
Add the following private fields to the StudentList Class:<br />
<source lang="java"><br />
private Database db ;<br />
private URI uri;<br />
</source><br />
Then modify its constructor to take and set thode fields:<br />
<source lang="java"><br />
public StudentList(Database db, URI uri) throws Exception {<br />
super(new StudentListComparator());<br />
this.db = db;<br />
this.uri = uri;<br />
SQLManager sqlManager = new SQLManager(db, uri);<br />
loadFrom(sqlManager.getStudents().elements()); <br />
SQLManager.closeDB();<br />
}<br />
<br />
</source><br />
<br />
11.7.1 Load list<br/><br />
As noticed above, the constructor then passes those objects to a new SQLiteManager object and gets students from the manager to load the list with. Then it closes the database.<br/><br />
<br />
11.7.2 Add Student<br/><br />
Now modify the addElement method:<br />
<source lang="java"><br />
/**<br />
* Adds a new element to the list.<br />
* @param element The element to be added.<br />
*/<br />
void addElement(Object element) {<br />
Student student = (Student) element;<br />
SQLManager sqlManager = new SQLManager(db, uri);<br />
sqlManager.addStudent(student.getFirstname(), student.getLastName(), student.getEmail(), student.getAddress());<br />
doAdd(element);<br />
SQLManager.closeDB();<br />
}<br />
<br />
</source><br />
11.7.3 Edit Student<br/><br />
And editElement method:<br />
<source lang="java"><br />
// added for Update:<br />
void updateElement(Object oldElement, Object newElement){<br />
Student student = (Student) newElement;<br />
SQLManager sqlManager = new SQLManager(db, uri);<br />
sqlManager.updateStudent(student.getId(), student.getFirstname(), student.getLastName(), student.getEmail(), student.getAddress());<br />
doUpdate(oldElement,newElement);<br />
SQLManager.closeDB();<br />
}<br />
<br />
<br />
</source><br />
11.7.4 Delete Student<br/><br />
<source lang="java"><br />
<br />
<br />
</source><br />
<br />
===11.8 Student View Application in Action===</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62371Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-12T04:16:27Z<p>Ladanzahir: /* 11.7 Modify StudentsList Class to use SQLiteManager */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Add SDCard to Simulator===<br />
To be able to have data preserved on database, first we need to make sure that simulator can simulate SDCard, so that we can run our application with database. For this purpose first create a folder on your file system. Then run the simulator and from the top menu choose: Simulate > Change SD Card... .<br/><br />
Then Mount Directory, and select the folder you just created. Every time you restart the simulator, before running the app you need to make sure that the folder is mounted as SD Card. later on you will see that the database file gets created there.<br/><br />
[[Image: BB_SDCard.png | 350px]]<br/><br />
<br />
===11.2 Create Database File===<br />
We would like to create a database file including out Student Entity, so that we can put it in the project. Then every time the app runs, first it checks if it is the first time run of the app on the device or simulator. If so, the app will copy the file in to the SDCard. Next time that you run the application, it will know that the file is there, so will not override it. <Br/><br />
<br />
For this purpose, create a simple blackberry project with only the application object. We do not need any screen here. call it "DBCreator".<br />
and this will need to only have a class called MyApp.java which extends UIApplication. Here is the code for this class:<br />
<br />
<source lang="java" ><br />
<br />
package mypackage;<br />
<br />
import java.util.Enumeration;<br />
import javax.microedition.io.file.FileSystemRegistry;<br />
import net.rim.device.api.ui.*;<br />
import net.rim.device.api.ui.component.*;<br />
import net.rim.device.api.database.*;<br />
import net.rim.device.api.io.*;<br />
<br />
/**<br />
* This class extends the UiApplication class, providing a<br />
* graphical user interface.<br />
*/<br />
public class MyApp extends UiApplication<br />
{<br />
private static String DB_NAME = "SQLiteStudentList";<br />
<br />
/**<br />
* Entry point for application<br />
* @param args Command line arguments (not used)<br />
*/<br />
public static void main(String[] args) throws Exception<br />
{<br />
// Create a new instance of the application and make the currently<br />
// running thread the application's event dispatch thread.<br />
MyApp theApp = new MyApp(); <br />
theApp.enterEventDispatcher();<br />
}<br />
<br />
<br />
/**<br />
* Creates a new MyApp object<br />
*/<br />
public MyApp()throws Exception<br />
{ <br />
// Check for the presence of the SDCard<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
try{<br />
// create a URI object with te file name and location <br />
String dbLocation = "/SDCard/databases/DBCreator/";<br />
URI uri = URI.create(dbLocation + DB_NAME);<br />
<br />
// open a database connection to that URI<br />
Database db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false));<br />
<br />
// create the table if it does not already exist<br />
Statement statement =<br />
db.createStatement("CREATE TABLE IF NOT EXISTS Student(id INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT, email TEXT, address TEXT)");<br />
statement.prepare();<br />
<br />
//execute the statement<br />
statement.execute();<br />
<br />
// close statement and database<br />
statement.close(); <br />
db.close(); <br />
<br />
}catch(Exception ex ) {<br />
errorDialog(ex.getMessage());<br />
System.exit(0); <br />
}<br />
<br />
}<br />
}<br />
<br />
// Error message dialog<br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
}<br />
<br />
</source><br />
<br />
Now run tha application. Then from the SDCard folder, drag the database file and drop it into your main project, "res" folder.<br />
<br />
===11.3 Add id to Student Class===<br />
Now in our main application project,we need to add id to this class because we are going to preserve our Student objects in database,:<br />
So add a private field and add public getter and setters:<br />
<source lang="java"><br />
<br />
public int getId(){<br />
return this.id;<br />
}<br />
public void setId(int id){<br />
this.id = id;<br />
}<br />
</source><br />
<br />
===11.4 Check for presence of SDCard===<br />
Each time our "Student View" application runs, we have to check for the presence of the SD card, and if it does not exist, we have to show a dialog message.<br />
<br />
Therefore, add the following code to the ViewStudentApp.java class constructor:<br />
<source lang="java"><br />
<br />
public ViewStudentApp() throws Exception {<br />
//This part is from BB Sample application<br />
// Determine if an SDCard is present<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
<br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
// the rest of code goes here<br />
<br />
}<br />
</source><br />
<br />
===11.5 Copy Database File into SDCard===<br />
Now that application knows SDCard is present, It should check if the database file exist, otherwise copy it from the application bundle into SDCard:<br />
<source lang="java"><br />
else<br />
{<br />
String dbLocation = "/SDCard/databases/StudentsList/";<br />
<br />
// Create URI <br />
uri = URI.create(dbLocation + DB_NAME); <br />
<br />
// Open or create a plain text database. This will create the<br />
// directory and file defined by the URI (if they do not already exist).<br />
db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false)); <br />
<br />
// Close the database in case it is blank and we need to write to the file<br />
db.close();<br />
<br />
// Open a connection to the database file <br />
FileConnection fileConnection = (FileConnection)Connector.open("file://" + dbLocation + DB_NAME); <br />
<br />
// If the file is blank, copy the pre-defined database from this<br />
// module to the SDCard.<br />
if(fileConnection.exists() && fileConnection.fileSize() == 0)<br />
{ <br />
readAndWriteDatabaseFile(fileConnection); <br />
} <br />
// here goes the rest of the constructor code<br />
_studentList = new StudentList(db, uri);<br />
</source><br />
<br />
Then add the following method (readAndWriteDatabaseFile) to the file that actually reads the database file and puts it into the simulator:<br />
<source lang="java"><br />
public void readAndWriteDatabaseFile(FileConnection fileConnection) throws IOException<br />
{ <br />
OutputStream outputStream = null;<br />
InputStream inputStream = null; <br />
<br />
// Open an input stream to the pre-defined encrypted database bundled<br />
// within this module.<br />
inputStream = getClass().getResourceAsStream("/" + DB_NAME);<br />
<br />
// Open an output stream to the newly created file<br />
outputStream = (OutputStream)fileConnection.openOutputStream(); <br />
<br />
// Read data from the input stream and write the data to the<br />
// output stream. <br />
byte[] data = new byte[256];<br />
int length = 0;<br />
while (-1 != (length = inputStream.read(data)))<br />
{<br />
outputStream.write(data, 0, length); <br />
} <br />
<br />
// Close the connections<br />
if(fileConnection != null)<br />
{<br />
fileConnection.close();<br />
}<br />
if(outputStream != null)<br />
{<br />
outputStream.close();<br />
}<br />
if(inputStream != null)<br />
{<br />
inputStream.close();<br />
} <br />
}<br />
<br />
</source><br />
<br />
===11.6 Create SQLiteManager Class===<br />
<br />
Now we need a class that will be the only class interacting with our database. It will take a Database object and a URI object to open database in the constructor. It will have methods to perform all the queries we need and at the end of each query will close the database. <br/><br />
<br />
So, create a class called: SQLiteManager, with 2 private fields, and a constructor that sets them and then tries to open database:<br />
<source lang="java"><br />
<br />
package cs.ecl.team1.project;<br />
<br />
<br />
<br />
import java.util.Vector;<br />
import net.rim.device.api.database.Cursor;<br />
import net.rim.device.api.database.DataTypeException;<br />
import net.rim.device.api.database.Database;<br />
import net.rim.device.api.database.DatabaseException;<br />
import net.rim.device.api.database.DatabaseFactory;<br />
import net.rim.device.api.database.Row;<br />
import net.rim.device.api.database.Statement;<br />
import net.rim.device.api.io.URI;<br />
import net.rim.device.api.ui.UiApplication;<br />
import net.rim.device.api.ui.component.Dialog;<br />
<br />
public class SQLManager {<br />
<br />
private static Database db;<br />
private URI uri;<br />
<br />
public SQLManager(Database db, URI uri)<br />
{<br />
this.uri = uri;<br />
this.db = db;<br />
openDB();<br />
}<br />
<br />
}<br />
</source><br />
'''11.6.1 Open Database'''<br/><br />
Then we implement the openDB() method:<br />
<source lang="java"><br />
void openDB()<br />
{ <br />
try<br />
{ <br />
this.db = DatabaseFactory.open(uri);<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
} <br />
</source><br />
'''11.6.2 Close Database'''<br/><br />
Then we definitely need a closeDB() method to use later:<br />
<source lang="java"><br />
static void closeDB()<br />
{ <br />
try<br />
{ <br />
db.close();<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
} <br />
</source><br />
And as you noticed above, we are going to need a method called errorDialog():<br />
<source lang="java"><br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
</source><br />
'''11.6.3 Insert New Student'''<br/><br />
The first query we need is a query that enables us add a new Student, so we need to implement a method for that:<br />
<source lang="java"><br />
//ADD STUDENT<br />
Student addStudent(String fName, String lName, String email, String address){<br />
Student student = null;<br />
try<br />
{<br />
<br />
<br />
Statement statement = db.createStatement("INSERT INTO Student VALUES(NULL,?,?,?,?)"); <br />
statement.prepare(); <br />
<br />
statement.bind(1,fName);<br />
statement.bind(2, lName);<br />
statement.bind(3, email);<br />
statement.bind(4, address);<br />
<br />
statement.execute();<br />
statement.close();<br />
<br />
statement = db.createStatement("SELECT id FROM Student WHERE firstName = ? AND lastName = ?");<br />
statement.prepare();<br />
statement.bind(1, fName); <br />
statement.bind(2, lName);<br />
Cursor cursor = statement.getCursor(); <br />
if(cursor.next())<br />
{<br />
Row row = cursor.getRow();<br />
int id = row.getInteger(0); <br />
student = new Student(id, fName, lName, email, address); <br />
} <br />
cursor.close();<br />
statement.close();<br />
}catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
} <br />
catch(DataTypeException dte)<br />
{<br />
errorDialog(dte.toString());<br />
}<br />
<br />
return student;<br />
}<br />
</source><br />
<br />
'''11.6.4 Delete Student'''<br/><br />
Then add a method to delete student by id:<br />
<br />
<source lang="java"><br />
// DELETE STUDENT<br />
<br />
void deleteStudent(int id)<br />
{<br />
try<br />
{<br />
<br />
Statement statement = db.createStatement("DELETE FROM Student WHERE id = ?");<br />
statement.prepare(); <br />
statement.bind(1, id);<br />
statement.execute(); <br />
statement.close();<br />
<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
} <br />
} <br />
</source><br />
'''11.6.5 Update Student'''<br/><br />
And a method to update Student:<br />
<source lang="java"><br />
//UPDATE STUDENT<br />
void updateStudent(int id, String fName, String lName, String email, String address)<br />
{<br />
try<br />
{ <br />
Statement statement = db.createStatement("UPDATE Student SET firstName = ?, lastName= ?, email = ?, address = ? WHERE id = ?");<br />
statement.prepare(); <br />
statement.bind(1, fName);<br />
statement.bind(2, lName);<br />
statement.bind(3, email);<br />
statement.bind(4, address);<br />
statement.bind(5, id); <br />
statement.execute(); <br />
statement.close();<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString()); <br />
} <br />
}<br />
<br />
</source><br />
<br />
'''11.6.6 Select All Students'''<br/><br />
And obviously we will need a method that gets all the students from database and returns a vector of Student, so that we can populate our student list:<br />
<source lang="java"><br />
Vector getStudents(){<br />
Vector students= new Vector();<br />
<br />
try<br />
{ <br />
<br />
Statement statement = db.createStatement("SELECT * FROM Student");<br />
statement.prepare();<br />
Cursor cursor = statement.getCursor();<br />
<br />
// Iterate through the the result set. For each row, add a<br />
// new DirectoryItem object to the vector.<br />
while(cursor.next())<br />
{ <br />
Row row = cursor.getRow();<br />
<br />
int id = row.getInteger(0);<br />
<br />
String fName = row.getString(1);<br />
String lName = row.getString(2);<br />
String email = row.getString(3); <br />
String address = row.getString(4);<br />
<br />
Student student = new Student(id, fName, lName, email, address);<br />
students.addElement(student); <br />
}<br />
statement.close();<br />
cursor.close();<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
catch(DataTypeException dte)<br />
{<br />
errorDialog(dte.toString());<br />
} <br />
<br />
return students; <br />
<br />
}<br />
</source><br />
<br />
===11.7 Modify StudentsList Class to use SQLiteManager===<br />
So far the StudentList class we have, consumes a vector to store students whiche are note preserved. We will modify the methods of this list to use the SQLiteManager and preserve the objects.<br/><br />
Add the following private fields to the StudentList Class:<br />
<source lang="java"><br />
private Database db ;<br />
private URI uri;<br />
</source><br />
Then modify its constructor to take and set thode fields:<br />
<source lang="java"><br />
public StudentList(Database db, URI uri) throws Exception {<br />
super(new StudentListComparator());<br />
this.db = db;<br />
this.uri = uri;<br />
SQLManager sqlManager = new SQLManager(db, uri);<br />
loadFrom(sqlManager.getStudents().elements()); <br />
SQLManager.closeDB();<br />
}<br />
<br />
</source><br />
<br />
11.7.1 Load list<br/><br />
<source lang="java"><br />
<br />
<br />
</source><br />
11.7.2 Add Student<br/><br />
<source lang="java"><br />
<br />
<br />
</source><br />
11.7.3 Edit Student<br/><br />
<source lang="java"><br />
<br />
<br />
</source><br />
11.7.4 Delete Student<br/><br />
<source lang="java"><br />
<br />
<br />
</source><br />
<br />
===11.8 Student View Application in Action===</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62370Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-12T04:11:28Z<p>Ladanzahir: /* 11.6 Create SQLiteManager Class */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Add SDCard to Simulator===<br />
To be able to have data preserved on database, first we need to make sure that simulator can simulate SDCard, so that we can run our application with database. For this purpose first create a folder on your file system. Then run the simulator and from the top menu choose: Simulate > Change SD Card... .<br/><br />
Then Mount Directory, and select the folder you just created. Every time you restart the simulator, before running the app you need to make sure that the folder is mounted as SD Card. later on you will see that the database file gets created there.<br/><br />
[[Image: BB_SDCard.png | 350px]]<br/><br />
<br />
===11.2 Create Database File===<br />
We would like to create a database file including out Student Entity, so that we can put it in the project. Then every time the app runs, first it checks if it is the first time run of the app on the device or simulator. If so, the app will copy the file in to the SDCard. Next time that you run the application, it will know that the file is there, so will not override it. <Br/><br />
<br />
For this purpose, create a simple blackberry project with only the application object. We do not need any screen here. call it "DBCreator".<br />
and this will need to only have a class called MyApp.java which extends UIApplication. Here is the code for this class:<br />
<br />
<source lang="java" ><br />
<br />
package mypackage;<br />
<br />
import java.util.Enumeration;<br />
import javax.microedition.io.file.FileSystemRegistry;<br />
import net.rim.device.api.ui.*;<br />
import net.rim.device.api.ui.component.*;<br />
import net.rim.device.api.database.*;<br />
import net.rim.device.api.io.*;<br />
<br />
/**<br />
* This class extends the UiApplication class, providing a<br />
* graphical user interface.<br />
*/<br />
public class MyApp extends UiApplication<br />
{<br />
private static String DB_NAME = "SQLiteStudentList";<br />
<br />
/**<br />
* Entry point for application<br />
* @param args Command line arguments (not used)<br />
*/<br />
public static void main(String[] args) throws Exception<br />
{<br />
// Create a new instance of the application and make the currently<br />
// running thread the application's event dispatch thread.<br />
MyApp theApp = new MyApp(); <br />
theApp.enterEventDispatcher();<br />
}<br />
<br />
<br />
/**<br />
* Creates a new MyApp object<br />
*/<br />
public MyApp()throws Exception<br />
{ <br />
// Check for the presence of the SDCard<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
try{<br />
// create a URI object with te file name and location <br />
String dbLocation = "/SDCard/databases/DBCreator/";<br />
URI uri = URI.create(dbLocation + DB_NAME);<br />
<br />
// open a database connection to that URI<br />
Database db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false));<br />
<br />
// create the table if it does not already exist<br />
Statement statement =<br />
db.createStatement("CREATE TABLE IF NOT EXISTS Student(id INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT, email TEXT, address TEXT)");<br />
statement.prepare();<br />
<br />
//execute the statement<br />
statement.execute();<br />
<br />
// close statement and database<br />
statement.close(); <br />
db.close(); <br />
<br />
}catch(Exception ex ) {<br />
errorDialog(ex.getMessage());<br />
System.exit(0); <br />
}<br />
<br />
}<br />
}<br />
<br />
// Error message dialog<br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
}<br />
<br />
</source><br />
<br />
Now run tha application. Then from the SDCard folder, drag the database file and drop it into your main project, "res" folder.<br />
<br />
===11.3 Add id to Student Class===<br />
Now in our main application project,we need to add id to this class because we are going to preserve our Student objects in database,:<br />
So add a private field and add public getter and setters:<br />
<source lang="java"><br />
<br />
public int getId(){<br />
return this.id;<br />
}<br />
public void setId(int id){<br />
this.id = id;<br />
}<br />
</source><br />
<br />
===11.4 Check for presence of SDCard===<br />
Each time our "Student View" application runs, we have to check for the presence of the SD card, and if it does not exist, we have to show a dialog message.<br />
<br />
Therefore, add the following code to the ViewStudentApp.java class constructor:<br />
<source lang="java"><br />
<br />
public ViewStudentApp() throws Exception {<br />
//This part is from BB Sample application<br />
// Determine if an SDCard is present<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
<br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
// the rest of code goes here<br />
<br />
}<br />
</source><br />
<br />
===11.5 Copy Database File into SDCard===<br />
Now that application knows SDCard is present, It should check if the database file exist, otherwise copy it from the application bundle into SDCard:<br />
<source lang="java"><br />
else<br />
{<br />
String dbLocation = "/SDCard/databases/StudentsList/";<br />
<br />
// Create URI <br />
uri = URI.create(dbLocation + DB_NAME); <br />
<br />
// Open or create a plain text database. This will create the<br />
// directory and file defined by the URI (if they do not already exist).<br />
db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false)); <br />
<br />
// Close the database in case it is blank and we need to write to the file<br />
db.close();<br />
<br />
// Open a connection to the database file <br />
FileConnection fileConnection = (FileConnection)Connector.open("file://" + dbLocation + DB_NAME); <br />
<br />
// If the file is blank, copy the pre-defined database from this<br />
// module to the SDCard.<br />
if(fileConnection.exists() && fileConnection.fileSize() == 0)<br />
{ <br />
readAndWriteDatabaseFile(fileConnection); <br />
} <br />
// here goes the rest of the constructor code<br />
_studentList = new StudentList(db, uri);<br />
</source><br />
<br />
Then add the following method (readAndWriteDatabaseFile) to the file that actually reads the database file and puts it into the simulator:<br />
<source lang="java"><br />
public void readAndWriteDatabaseFile(FileConnection fileConnection) throws IOException<br />
{ <br />
OutputStream outputStream = null;<br />
InputStream inputStream = null; <br />
<br />
// Open an input stream to the pre-defined encrypted database bundled<br />
// within this module.<br />
inputStream = getClass().getResourceAsStream("/" + DB_NAME);<br />
<br />
// Open an output stream to the newly created file<br />
outputStream = (OutputStream)fileConnection.openOutputStream(); <br />
<br />
// Read data from the input stream and write the data to the<br />
// output stream. <br />
byte[] data = new byte[256];<br />
int length = 0;<br />
while (-1 != (length = inputStream.read(data)))<br />
{<br />
outputStream.write(data, 0, length); <br />
} <br />
<br />
// Close the connections<br />
if(fileConnection != null)<br />
{<br />
fileConnection.close();<br />
}<br />
if(outputStream != null)<br />
{<br />
outputStream.close();<br />
}<br />
if(inputStream != null)<br />
{<br />
inputStream.close();<br />
} <br />
}<br />
<br />
</source><br />
<br />
===11.6 Create SQLiteManager Class===<br />
<br />
Now we need a class that will be the only class interacting with our database. It will take a Database object and a URI object to open database in the constructor. It will have methods to perform all the queries we need and at the end of each query will close the database. <br/><br />
<br />
So, create a class called: SQLiteManager, with 2 private fields, and a constructor that sets them and then tries to open database:<br />
<source lang="java"><br />
<br />
package cs.ecl.team1.project;<br />
<br />
<br />
<br />
import java.util.Vector;<br />
import net.rim.device.api.database.Cursor;<br />
import net.rim.device.api.database.DataTypeException;<br />
import net.rim.device.api.database.Database;<br />
import net.rim.device.api.database.DatabaseException;<br />
import net.rim.device.api.database.DatabaseFactory;<br />
import net.rim.device.api.database.Row;<br />
import net.rim.device.api.database.Statement;<br />
import net.rim.device.api.io.URI;<br />
import net.rim.device.api.ui.UiApplication;<br />
import net.rim.device.api.ui.component.Dialog;<br />
<br />
public class SQLManager {<br />
<br />
private static Database db;<br />
private URI uri;<br />
<br />
public SQLManager(Database db, URI uri)<br />
{<br />
this.uri = uri;<br />
this.db = db;<br />
openDB();<br />
}<br />
<br />
}<br />
</source><br />
'''11.6.1 Open Database'''<br/><br />
Then we implement the openDB() method:<br />
<source lang="java"><br />
void openDB()<br />
{ <br />
try<br />
{ <br />
this.db = DatabaseFactory.open(uri);<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
} <br />
</source><br />
'''11.6.2 Close Database'''<br/><br />
Then we definitely need a closeDB() method to use later:<br />
<source lang="java"><br />
static void closeDB()<br />
{ <br />
try<br />
{ <br />
db.close();<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
} <br />
</source><br />
And as you noticed above, we are going to need a method called errorDialog():<br />
<source lang="java"><br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
</source><br />
'''11.6.3 Insert New Student'''<br/><br />
The first query we need is a query that enables us add a new Student, so we need to implement a method for that:<br />
<source lang="java"><br />
//ADD STUDENT<br />
Student addStudent(String fName, String lName, String email, String address){<br />
Student student = null;<br />
try<br />
{<br />
<br />
<br />
Statement statement = db.createStatement("INSERT INTO Student VALUES(NULL,?,?,?,?)"); <br />
statement.prepare(); <br />
<br />
statement.bind(1,fName);<br />
statement.bind(2, lName);<br />
statement.bind(3, email);<br />
statement.bind(4, address);<br />
<br />
statement.execute();<br />
statement.close();<br />
<br />
statement = db.createStatement("SELECT id FROM Student WHERE firstName = ? AND lastName = ?");<br />
statement.prepare();<br />
statement.bind(1, fName); <br />
statement.bind(2, lName);<br />
Cursor cursor = statement.getCursor(); <br />
if(cursor.next())<br />
{<br />
Row row = cursor.getRow();<br />
int id = row.getInteger(0); <br />
student = new Student(id, fName, lName, email, address); <br />
} <br />
cursor.close();<br />
statement.close();<br />
}catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
} <br />
catch(DataTypeException dte)<br />
{<br />
errorDialog(dte.toString());<br />
}<br />
<br />
return student;<br />
}<br />
</source><br />
<br />
'''11.6.4 Delete Student'''<br/><br />
Then add a method to delete student by id:<br />
<br />
<source lang="java"><br />
// DELETE STUDENT<br />
<br />
void deleteStudent(int id)<br />
{<br />
try<br />
{<br />
<br />
Statement statement = db.createStatement("DELETE FROM Student WHERE id = ?");<br />
statement.prepare(); <br />
statement.bind(1, id);<br />
statement.execute(); <br />
statement.close();<br />
<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
} <br />
} <br />
</source><br />
'''11.6.5 Update Student'''<br/><br />
And a method to update Student:<br />
<source lang="java"><br />
//UPDATE STUDENT<br />
void updateStudent(int id, String fName, String lName, String email, String address)<br />
{<br />
try<br />
{ <br />
Statement statement = db.createStatement("UPDATE Student SET firstName = ?, lastName= ?, email = ?, address = ? WHERE id = ?");<br />
statement.prepare(); <br />
statement.bind(1, fName);<br />
statement.bind(2, lName);<br />
statement.bind(3, email);<br />
statement.bind(4, address);<br />
statement.bind(5, id); <br />
statement.execute(); <br />
statement.close();<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString()); <br />
} <br />
}<br />
<br />
</source><br />
<br />
'''11.6.6 Select All Students'''<br/><br />
And obviously we will need a method that gets all the students from database and returns a vector of Student, so that we can populate our student list:<br />
<source lang="java"><br />
Vector getStudents(){<br />
Vector students= new Vector();<br />
<br />
try<br />
{ <br />
<br />
Statement statement = db.createStatement("SELECT * FROM Student");<br />
statement.prepare();<br />
Cursor cursor = statement.getCursor();<br />
<br />
// Iterate through the the result set. For each row, add a<br />
// new DirectoryItem object to the vector.<br />
while(cursor.next())<br />
{ <br />
Row row = cursor.getRow();<br />
<br />
int id = row.getInteger(0);<br />
<br />
String fName = row.getString(1);<br />
String lName = row.getString(2);<br />
String email = row.getString(3); <br />
String address = row.getString(4);<br />
<br />
Student student = new Student(id, fName, lName, email, address);<br />
students.addElement(student); <br />
}<br />
statement.close();<br />
cursor.close();<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
catch(DataTypeException dte)<br />
{<br />
errorDialog(dte.toString());<br />
} <br />
<br />
return students; <br />
<br />
}<br />
</source><br />
<br />
===11.7 Modify StudentsList Class to use SQLiteManager===<br />
11.7.1 Load list<br/><br />
11.7.2 Add Student<br/><br />
11.7.3 Edit Student<br/><br />
11.7.4 Delete Student<br/><br />
<br />
===11.8 Student View Application in Action===</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62369Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-12T04:10:43Z<p>Ladanzahir: /* 11.6 Create SQLiteManager Class */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Add SDCard to Simulator===<br />
To be able to have data preserved on database, first we need to make sure that simulator can simulate SDCard, so that we can run our application with database. For this purpose first create a folder on your file system. Then run the simulator and from the top menu choose: Simulate > Change SD Card... .<br/><br />
Then Mount Directory, and select the folder you just created. Every time you restart the simulator, before running the app you need to make sure that the folder is mounted as SD Card. later on you will see that the database file gets created there.<br/><br />
[[Image: BB_SDCard.png | 350px]]<br/><br />
<br />
===11.2 Create Database File===<br />
We would like to create a database file including out Student Entity, so that we can put it in the project. Then every time the app runs, first it checks if it is the first time run of the app on the device or simulator. If so, the app will copy the file in to the SDCard. Next time that you run the application, it will know that the file is there, so will not override it. <Br/><br />
<br />
For this purpose, create a simple blackberry project with only the application object. We do not need any screen here. call it "DBCreator".<br />
and this will need to only have a class called MyApp.java which extends UIApplication. Here is the code for this class:<br />
<br />
<source lang="java" ><br />
<br />
package mypackage;<br />
<br />
import java.util.Enumeration;<br />
import javax.microedition.io.file.FileSystemRegistry;<br />
import net.rim.device.api.ui.*;<br />
import net.rim.device.api.ui.component.*;<br />
import net.rim.device.api.database.*;<br />
import net.rim.device.api.io.*;<br />
<br />
/**<br />
* This class extends the UiApplication class, providing a<br />
* graphical user interface.<br />
*/<br />
public class MyApp extends UiApplication<br />
{<br />
private static String DB_NAME = "SQLiteStudentList";<br />
<br />
/**<br />
* Entry point for application<br />
* @param args Command line arguments (not used)<br />
*/<br />
public static void main(String[] args) throws Exception<br />
{<br />
// Create a new instance of the application and make the currently<br />
// running thread the application's event dispatch thread.<br />
MyApp theApp = new MyApp(); <br />
theApp.enterEventDispatcher();<br />
}<br />
<br />
<br />
/**<br />
* Creates a new MyApp object<br />
*/<br />
public MyApp()throws Exception<br />
{ <br />
// Check for the presence of the SDCard<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
try{<br />
// create a URI object with te file name and location <br />
String dbLocation = "/SDCard/databases/DBCreator/";<br />
URI uri = URI.create(dbLocation + DB_NAME);<br />
<br />
// open a database connection to that URI<br />
Database db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false));<br />
<br />
// create the table if it does not already exist<br />
Statement statement =<br />
db.createStatement("CREATE TABLE IF NOT EXISTS Student(id INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT, email TEXT, address TEXT)");<br />
statement.prepare();<br />
<br />
//execute the statement<br />
statement.execute();<br />
<br />
// close statement and database<br />
statement.close(); <br />
db.close(); <br />
<br />
}catch(Exception ex ) {<br />
errorDialog(ex.getMessage());<br />
System.exit(0); <br />
}<br />
<br />
}<br />
}<br />
<br />
// Error message dialog<br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
}<br />
<br />
</source><br />
<br />
Now run tha application. Then from the SDCard folder, drag the database file and drop it into your main project, "res" folder.<br />
<br />
===11.3 Add id to Student Class===<br />
Now in our main application project,we need to add id to this class because we are going to preserve our Student objects in database,:<br />
So add a private field and add public getter and setters:<br />
<source lang="java"><br />
<br />
public int getId(){<br />
return this.id;<br />
}<br />
public void setId(int id){<br />
this.id = id;<br />
}<br />
</source><br />
<br />
===11.4 Check for presence of SDCard===<br />
Each time our "Student View" application runs, we have to check for the presence of the SD card, and if it does not exist, we have to show a dialog message.<br />
<br />
Therefore, add the following code to the ViewStudentApp.java class constructor:<br />
<source lang="java"><br />
<br />
public ViewStudentApp() throws Exception {<br />
//This part is from BB Sample application<br />
// Determine if an SDCard is present<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
<br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
// the rest of code goes here<br />
<br />
}<br />
</source><br />
<br />
===11.5 Copy Database File into SDCard===<br />
Now that application knows SDCard is present, It should check if the database file exist, otherwise copy it from the application bundle into SDCard:<br />
<source lang="java"><br />
else<br />
{<br />
String dbLocation = "/SDCard/databases/StudentsList/";<br />
<br />
// Create URI <br />
uri = URI.create(dbLocation + DB_NAME); <br />
<br />
// Open or create a plain text database. This will create the<br />
// directory and file defined by the URI (if they do not already exist).<br />
db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false)); <br />
<br />
// Close the database in case it is blank and we need to write to the file<br />
db.close();<br />
<br />
// Open a connection to the database file <br />
FileConnection fileConnection = (FileConnection)Connector.open("file://" + dbLocation + DB_NAME); <br />
<br />
// If the file is blank, copy the pre-defined database from this<br />
// module to the SDCard.<br />
if(fileConnection.exists() && fileConnection.fileSize() == 0)<br />
{ <br />
readAndWriteDatabaseFile(fileConnection); <br />
} <br />
// here goes the rest of the constructor code<br />
_studentList = new StudentList(db, uri);<br />
</source><br />
<br />
Then add the following method (readAndWriteDatabaseFile) to the file that actually reads the database file and puts it into the simulator:<br />
<source lang="java"><br />
public void readAndWriteDatabaseFile(FileConnection fileConnection) throws IOException<br />
{ <br />
OutputStream outputStream = null;<br />
InputStream inputStream = null; <br />
<br />
// Open an input stream to the pre-defined encrypted database bundled<br />
// within this module.<br />
inputStream = getClass().getResourceAsStream("/" + DB_NAME);<br />
<br />
// Open an output stream to the newly created file<br />
outputStream = (OutputStream)fileConnection.openOutputStream(); <br />
<br />
// Read data from the input stream and write the data to the<br />
// output stream. <br />
byte[] data = new byte[256];<br />
int length = 0;<br />
while (-1 != (length = inputStream.read(data)))<br />
{<br />
outputStream.write(data, 0, length); <br />
} <br />
<br />
// Close the connections<br />
if(fileConnection != null)<br />
{<br />
fileConnection.close();<br />
}<br />
if(outputStream != null)<br />
{<br />
outputStream.close();<br />
}<br />
if(inputStream != null)<br />
{<br />
inputStream.close();<br />
} <br />
}<br />
<br />
</source><br />
<br />
===11.6 Create SQLiteManager Class===<br />
<br />
Now we need a class that will be the only class interacting with our database. It will take a Database object and a URI object to open database in the constructor. It will have methods to perform all the queries we need and at the end of each query will close the database. <br/><br />
<br />
So, create a class called: SQLiteManager, with 2 private fields, and a constructor that sets them and then tries to open database:<br />
<source lang="java"><br />
<br />
package cs.ecl.team1.project;<br />
<br />
<br />
<br />
import java.util.Vector;<br />
import net.rim.device.api.database.Cursor;<br />
import net.rim.device.api.database.DataTypeException;<br />
import net.rim.device.api.database.Database;<br />
import net.rim.device.api.database.DatabaseException;<br />
import net.rim.device.api.database.DatabaseFactory;<br />
import net.rim.device.api.database.Row;<br />
import net.rim.device.api.database.Statement;<br />
import net.rim.device.api.io.URI;<br />
import net.rim.device.api.ui.UiApplication;<br />
import net.rim.device.api.ui.component.Dialog;<br />
<br />
public class SQLManager {<br />
<br />
private static Database db;<br />
private URI uri;<br />
<br />
public SQLManager(Database db, URI uri)<br />
{<br />
this.uri = uri;<br />
this.db = db;<br />
openDB();<br />
}<br />
<br />
}<br />
</source><br />
'''11.6.1 Open Database'''<br/><br />
Then we implement the openDB() method:<br />
<source lang="java"><br />
void openDB()<br />
{ <br />
try<br />
{ <br />
this.db = DatabaseFactory.open(uri);<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
} <br />
</source><br />
'''11.6.2 Close Database'''<br/><br />
Then we definitely need a closeDB() method to use later:<br />
<source lang="java"><br />
static void closeDB()<br />
{ <br />
try<br />
{ <br />
db.close();<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
} <br />
</source><br />
And as you noticed above, we are going to need a method called errorDialog():<br />
<source lang="java"><br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
</source><br />
'''11.6.3 Insert New Student'''<br/><br />
The first query we need is a query that enables us add a new Student, so we need to implement a method for that:<br />
<source lang="java"><br />
//ADD STUDENT<br />
Student addStudent(String fName, String lName, String email, String address){<br />
Student student = null;<br />
try<br />
{<br />
<br />
<br />
Statement statement = db.createStatement("INSERT INTO Student VALUES(NULL,?,?,?,?)"); <br />
statement.prepare(); <br />
<br />
statement.bind(1,fName);<br />
statement.bind(2, lName);<br />
statement.bind(3, email);<br />
statement.bind(4, address);<br />
<br />
statement.execute();<br />
statement.close();<br />
<br />
statement = db.createStatement("SELECT id FROM Student WHERE firstName = ? AND lastName = ?");<br />
statement.prepare();<br />
statement.bind(1, fName); <br />
statement.bind(2, lName);<br />
Cursor cursor = statement.getCursor(); <br />
if(cursor.next())<br />
{<br />
Row row = cursor.getRow();<br />
int id = row.getInteger(0); <br />
student = new Student(id, fName, lName, email, address); <br />
} <br />
cursor.close();<br />
statement.close();<br />
}catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
} <br />
catch(DataTypeException dte)<br />
{<br />
errorDialog(dte.toString());<br />
}<br />
<br />
return student;<br />
}<br />
</source><br />
<br />
'''11.6.4 Delete Student'''<br/><br />
Then add a method to delete student by id:<br />
<br />
<source lang="java"><br />
// DELETE STUDENT<br />
<br />
void deleteStudent(int id)<br />
{<br />
try<br />
{<br />
<br />
Statement statement = db.createStatement("DELETE FROM Student WHERE id = ?");<br />
statement.prepare(); <br />
statement.bind(1, id);<br />
statement.execute(); <br />
statement.close();<br />
<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
} <br />
} <br />
</source><br />
'''11.6.5 Update Student'''<br/><br />
And a method to update Student:<br />
<source lang="java"><br />
//UPDATE STUDENT<br />
void updateStudent(int id, String fName, String lName, String email, String address)<br />
{<br />
try<br />
{ <br />
Statement statement = db.createStatement("UPDATE Student SET firstName = ?, lastName= ?, email = ?, address = ? WHERE id = ?");<br />
statement.prepare(); <br />
statement.bind(1, fName);<br />
statement.bind(2, lName);<br />
statement.bind(3, email);<br />
statement.bind(4, address);<br />
statement.bind(5, id); <br />
statement.execute(); <br />
statement.close();<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString()); <br />
} <br />
}<br />
<br />
</source><br />
<br />
'''11.6.6 Select All Students'''<br/><br />
And obviously we will need a method that gets all the students from database and returns a vector of type Student, so that we can populate our student list:<br />
<source lang="java"><br />
Vector getStudents(){<br />
Vector students= new Vector();<br />
<br />
try<br />
{ <br />
<br />
Statement statement = db.createStatement("SELECT * FROM Student");<br />
statement.prepare();<br />
Cursor cursor = statement.getCursor();<br />
<br />
// Iterate through the the result set. For each row, add a<br />
// new DirectoryItem object to the vector.<br />
while(cursor.next())<br />
{ <br />
Row row = cursor.getRow();<br />
<br />
int id = row.getInteger(0);<br />
<br />
String fName = row.getString(1);<br />
String lName = row.getString(2);<br />
String email = row.getString(3); <br />
String address = row.getString(4);<br />
<br />
Student student = new Student(id, fName, lName, email, address);<br />
students.addElement(student); <br />
}<br />
statement.close();<br />
cursor.close();<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
catch(DataTypeException dte)<br />
{<br />
errorDialog(dte.toString());<br />
} <br />
<br />
return students; <br />
<br />
}<br />
</source><br />
<br />
===11.7 Modify StudentsList Class to use SQLiteManager===<br />
11.7.1 Load list<br/><br />
11.7.2 Add Student<br/><br />
11.7.3 Edit Student<br/><br />
11.7.4 Delete Student<br/><br />
<br />
===11.8 Student View Application in Action===</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62368Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-12T04:10:10Z<p>Ladanzahir: /* 11.6 Create SQLiteManager Class */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Add SDCard to Simulator===<br />
To be able to have data preserved on database, first we need to make sure that simulator can simulate SDCard, so that we can run our application with database. For this purpose first create a folder on your file system. Then run the simulator and from the top menu choose: Simulate > Change SD Card... .<br/><br />
Then Mount Directory, and select the folder you just created. Every time you restart the simulator, before running the app you need to make sure that the folder is mounted as SD Card. later on you will see that the database file gets created there.<br/><br />
[[Image: BB_SDCard.png | 350px]]<br/><br />
<br />
===11.2 Create Database File===<br />
We would like to create a database file including out Student Entity, so that we can put it in the project. Then every time the app runs, first it checks if it is the first time run of the app on the device or simulator. If so, the app will copy the file in to the SDCard. Next time that you run the application, it will know that the file is there, so will not override it. <Br/><br />
<br />
For this purpose, create a simple blackberry project with only the application object. We do not need any screen here. call it "DBCreator".<br />
and this will need to only have a class called MyApp.java which extends UIApplication. Here is the code for this class:<br />
<br />
<source lang="java" ><br />
<br />
package mypackage;<br />
<br />
import java.util.Enumeration;<br />
import javax.microedition.io.file.FileSystemRegistry;<br />
import net.rim.device.api.ui.*;<br />
import net.rim.device.api.ui.component.*;<br />
import net.rim.device.api.database.*;<br />
import net.rim.device.api.io.*;<br />
<br />
/**<br />
* This class extends the UiApplication class, providing a<br />
* graphical user interface.<br />
*/<br />
public class MyApp extends UiApplication<br />
{<br />
private static String DB_NAME = "SQLiteStudentList";<br />
<br />
/**<br />
* Entry point for application<br />
* @param args Command line arguments (not used)<br />
*/<br />
public static void main(String[] args) throws Exception<br />
{<br />
// Create a new instance of the application and make the currently<br />
// running thread the application's event dispatch thread.<br />
MyApp theApp = new MyApp(); <br />
theApp.enterEventDispatcher();<br />
}<br />
<br />
<br />
/**<br />
* Creates a new MyApp object<br />
*/<br />
public MyApp()throws Exception<br />
{ <br />
// Check for the presence of the SDCard<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
try{<br />
// create a URI object with te file name and location <br />
String dbLocation = "/SDCard/databases/DBCreator/";<br />
URI uri = URI.create(dbLocation + DB_NAME);<br />
<br />
// open a database connection to that URI<br />
Database db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false));<br />
<br />
// create the table if it does not already exist<br />
Statement statement =<br />
db.createStatement("CREATE TABLE IF NOT EXISTS Student(id INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT, email TEXT, address TEXT)");<br />
statement.prepare();<br />
<br />
//execute the statement<br />
statement.execute();<br />
<br />
// close statement and database<br />
statement.close(); <br />
db.close(); <br />
<br />
}catch(Exception ex ) {<br />
errorDialog(ex.getMessage());<br />
System.exit(0); <br />
}<br />
<br />
}<br />
}<br />
<br />
// Error message dialog<br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
}<br />
<br />
</source><br />
<br />
Now run tha application. Then from the SDCard folder, drag the database file and drop it into your main project, "res" folder.<br />
<br />
===11.3 Add id to Student Class===<br />
Now in our main application project,we need to add id to this class because we are going to preserve our Student objects in database,:<br />
So add a private field and add public getter and setters:<br />
<source lang="java"><br />
<br />
public int getId(){<br />
return this.id;<br />
}<br />
public void setId(int id){<br />
this.id = id;<br />
}<br />
</source><br />
<br />
===11.4 Check for presence of SDCard===<br />
Each time our "Student View" application runs, we have to check for the presence of the SD card, and if it does not exist, we have to show a dialog message.<br />
<br />
Therefore, add the following code to the ViewStudentApp.java class constructor:<br />
<source lang="java"><br />
<br />
public ViewStudentApp() throws Exception {<br />
//This part is from BB Sample application<br />
// Determine if an SDCard is present<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
<br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
// the rest of code goes here<br />
<br />
}<br />
</source><br />
<br />
===11.5 Copy Database File into SDCard===<br />
Now that application knows SDCard is present, It should check if the database file exist, otherwise copy it from the application bundle into SDCard:<br />
<source lang="java"><br />
else<br />
{<br />
String dbLocation = "/SDCard/databases/StudentsList/";<br />
<br />
// Create URI <br />
uri = URI.create(dbLocation + DB_NAME); <br />
<br />
// Open or create a plain text database. This will create the<br />
// directory and file defined by the URI (if they do not already exist).<br />
db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false)); <br />
<br />
// Close the database in case it is blank and we need to write to the file<br />
db.close();<br />
<br />
// Open a connection to the database file <br />
FileConnection fileConnection = (FileConnection)Connector.open("file://" + dbLocation + DB_NAME); <br />
<br />
// If the file is blank, copy the pre-defined database from this<br />
// module to the SDCard.<br />
if(fileConnection.exists() && fileConnection.fileSize() == 0)<br />
{ <br />
readAndWriteDatabaseFile(fileConnection); <br />
} <br />
// here goes the rest of the constructor code<br />
_studentList = new StudentList(db, uri);<br />
</source><br />
<br />
Then add the following method (readAndWriteDatabaseFile) to the file that actually reads the database file and puts it into the simulator:<br />
<source lang="java"><br />
public void readAndWriteDatabaseFile(FileConnection fileConnection) throws IOException<br />
{ <br />
OutputStream outputStream = null;<br />
InputStream inputStream = null; <br />
<br />
// Open an input stream to the pre-defined encrypted database bundled<br />
// within this module.<br />
inputStream = getClass().getResourceAsStream("/" + DB_NAME);<br />
<br />
// Open an output stream to the newly created file<br />
outputStream = (OutputStream)fileConnection.openOutputStream(); <br />
<br />
// Read data from the input stream and write the data to the<br />
// output stream. <br />
byte[] data = new byte[256];<br />
int length = 0;<br />
while (-1 != (length = inputStream.read(data)))<br />
{<br />
outputStream.write(data, 0, length); <br />
} <br />
<br />
// Close the connections<br />
if(fileConnection != null)<br />
{<br />
fileConnection.close();<br />
}<br />
if(outputStream != null)<br />
{<br />
outputStream.close();<br />
}<br />
if(inputStream != null)<br />
{<br />
inputStream.close();<br />
} <br />
}<br />
<br />
</source><br />
<br />
===11.6 Create SQLiteManager Class===<br />
<br />
Now we need a class that will be the only class interacting with our database. It will take a Database object and a URI object to open database in the constructor. It will have methods to perform all the queries we need and at the end of each query will close the database. <br/><br />
<br />
So, create a class called: SQLiteManager, with 2 private fields, and a constructor that sets them and then tries to open database:<br />
<source lang="java"><br />
<br />
package cs.ecl.team1.project;<br />
<br />
<br />
<br />
import java.util.Vector;<br />
import net.rim.device.api.database.Cursor;<br />
import net.rim.device.api.database.DataTypeException;<br />
import net.rim.device.api.database.Database;<br />
import net.rim.device.api.database.DatabaseException;<br />
import net.rim.device.api.database.DatabaseFactory;<br />
import net.rim.device.api.database.Row;<br />
import net.rim.device.api.database.Statement;<br />
import net.rim.device.api.io.URI;<br />
import net.rim.device.api.ui.UiApplication;<br />
import net.rim.device.api.ui.component.Dialog;<br />
<br />
public class SQLManager {<br />
<br />
private static Database db;<br />
private URI uri;<br />
<br />
public SQLManager(Database db, URI uri)<br />
{<br />
this.uri = uri;<br />
this.db = db;<br />
openDB();<br />
}<br />
<br />
}<br />
</source><br />
'''11.6.1 Open Database'''<br/><br />
Then we implement the openDB() method:<br />
<source lang="java"><br />
void openDB()<br />
{ <br />
try<br />
{ <br />
this.db = DatabaseFactory.open(uri);<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
} <br />
</source><br />
'''11.6.2 Close Database'''<br/><br />
Then we definitely need a closeDB() method to use later:<br />
<source lang="java"><br />
static void closeDB()<br />
{ <br />
try<br />
{ <br />
db.close();<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
} <br />
</source><br />
And as you noticed above, we are going to need a method called errorDialog():<br />
<source lang="java"><br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
</source><br />
'''11.6.3 Insert New Student'''<br/><br />
The first query we need is a query that enables us add a new Student, so we need to implement a method for that:<br />
<source lang="java"><br />
//ADD STUDENT<br />
Student addStudent(String fName, String lName, String email, String address){<br />
Student student = null;<br />
try<br />
{<br />
<br />
<br />
Statement statement = db.createStatement("INSERT INTO Student VALUES(NULL,?,?,?,?)"); <br />
statement.prepare(); <br />
<br />
statement.bind(1,fName);<br />
statement.bind(2, lName);<br />
statement.bind(3, email);<br />
statement.bind(4, address);<br />
<br />
statement.execute();<br />
statement.close();<br />
<br />
statement = db.createStatement("SELECT id FROM Student WHERE firstName = ? AND lastName = ?");<br />
statement.prepare();<br />
statement.bind(1, fName); <br />
statement.bind(2, lName);<br />
Cursor cursor = statement.getCursor(); <br />
if(cursor.next())<br />
{<br />
Row row = cursor.getRow();<br />
int id = row.getInteger(0); <br />
student = new Student(id, fName, lName, email, address); <br />
} <br />
cursor.close();<br />
statement.close();<br />
}catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
} <br />
catch(DataTypeException dte)<br />
{<br />
errorDialog(dte.toString());<br />
}<br />
<br />
return student;<br />
}<br />
</source><br />
<br />
'''11.6.4 Delete Student'''<br/><br />
Then add a method to delete student by id:<br />
<br />
<source lang="java"><br />
// DELETE STUDENT<br />
<br />
void deleteStudent(int id)<br />
{<br />
try<br />
{<br />
<br />
Statement statement = db.createStatement("DELETE FROM Student WHERE id = ?");<br />
statement.prepare(); <br />
statement.bind(1, id);<br />
statement.execute(); <br />
statement.close();<br />
<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
} <br />
} <br />
</source><br />
'''11.6.5 Update Student'''<br/><br />
And a method to update Student:<br />
<source lang="java"><br />
//UPDATE STUDENT<br />
void updateStudent(int id, String fName, String lName, String email, String address)<br />
{<br />
try<br />
{ <br />
Statement statement = db.createStatement("UPDATE Student SET firstName = ?, lastName= ?, email = ?, address = ? WHERE id = ?");<br />
statement.prepare(); <br />
statement.bind(1, fName);<br />
statement.bind(2, lName);<br />
statement.bind(3, email);<br />
statement.bind(4, address);<br />
statement.bind(5, id); <br />
statement.execute(); <br />
statement.close();<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString()); <br />
} <br />
}<br />
<br />
</source><br />
<br />
'''11.6.6 Select All Students'''<br/><br />
And obviously we will need a method that gets all the students from database and returns a vector of type Student, so that we can populate our student list:<br />
<source lang="java"><br />
Vector getStudents(){<br />
Vector students= new Vector();<br />
<br />
try<br />
{ <br />
<br />
Statement statement = db.createStatement("SELECT * FROM Student");<br />
statement.prepare();<br />
Cursor cursor = statement.getCursor();<br />
<br />
// Iterate through the the result set. For each row, add a<br />
// new DirectoryItem object to the vector.<br />
while(cursor.next())<br />
{ <br />
Row row = cursor.getRow();<br />
<br />
int id = row.getInteger(0);<br />
<br />
String fName = row.getString(1);<br />
String lName = row.getString(2);<br />
String email = row.getString(3); <br />
String address = row.getString(4);<br />
<br />
Student student = new Student(id, fName, lName, email, address);<br />
students.addElement(student); <br />
}<br />
statement.close();<br />
cursor.close();<br />
<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
catch(DataTypeException dte)<br />
{<br />
errorDialog(dte.toString());<br />
} <br />
<br />
return students; <br />
<br />
}<br />
</source><br />
<br />
===11.7 Modify StudentsList Class to use SQLiteManager===<br />
11.7.1 Load list<br/><br />
11.7.2 Add Student<br/><br />
11.7.3 Edit Student<br/><br />
11.7.4 Delete Student<br/><br />
<br />
===11.8 Student View Application in Action===</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62367Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-12T04:05:00Z<p>Ladanzahir: /* 11.6 Create SQLiteManager Class */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Add SDCard to Simulator===<br />
To be able to have data preserved on database, first we need to make sure that simulator can simulate SDCard, so that we can run our application with database. For this purpose first create a folder on your file system. Then run the simulator and from the top menu choose: Simulate > Change SD Card... .<br/><br />
Then Mount Directory, and select the folder you just created. Every time you restart the simulator, before running the app you need to make sure that the folder is mounted as SD Card. later on you will see that the database file gets created there.<br/><br />
[[Image: BB_SDCard.png | 350px]]<br/><br />
<br />
===11.2 Create Database File===<br />
We would like to create a database file including out Student Entity, so that we can put it in the project. Then every time the app runs, first it checks if it is the first time run of the app on the device or simulator. If so, the app will copy the file in to the SDCard. Next time that you run the application, it will know that the file is there, so will not override it. <Br/><br />
<br />
For this purpose, create a simple blackberry project with only the application object. We do not need any screen here. call it "DBCreator".<br />
and this will need to only have a class called MyApp.java which extends UIApplication. Here is the code for this class:<br />
<br />
<source lang="java" ><br />
<br />
package mypackage;<br />
<br />
import java.util.Enumeration;<br />
import javax.microedition.io.file.FileSystemRegistry;<br />
import net.rim.device.api.ui.*;<br />
import net.rim.device.api.ui.component.*;<br />
import net.rim.device.api.database.*;<br />
import net.rim.device.api.io.*;<br />
<br />
/**<br />
* This class extends the UiApplication class, providing a<br />
* graphical user interface.<br />
*/<br />
public class MyApp extends UiApplication<br />
{<br />
private static String DB_NAME = "SQLiteStudentList";<br />
<br />
/**<br />
* Entry point for application<br />
* @param args Command line arguments (not used)<br />
*/<br />
public static void main(String[] args) throws Exception<br />
{<br />
// Create a new instance of the application and make the currently<br />
// running thread the application's event dispatch thread.<br />
MyApp theApp = new MyApp(); <br />
theApp.enterEventDispatcher();<br />
}<br />
<br />
<br />
/**<br />
* Creates a new MyApp object<br />
*/<br />
public MyApp()throws Exception<br />
{ <br />
// Check for the presence of the SDCard<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
try{<br />
// create a URI object with te file name and location <br />
String dbLocation = "/SDCard/databases/DBCreator/";<br />
URI uri = URI.create(dbLocation + DB_NAME);<br />
<br />
// open a database connection to that URI<br />
Database db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false));<br />
<br />
// create the table if it does not already exist<br />
Statement statement =<br />
db.createStatement("CREATE TABLE IF NOT EXISTS Student(id INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT, email TEXT, address TEXT)");<br />
statement.prepare();<br />
<br />
//execute the statement<br />
statement.execute();<br />
<br />
// close statement and database<br />
statement.close(); <br />
db.close(); <br />
<br />
}catch(Exception ex ) {<br />
errorDialog(ex.getMessage());<br />
System.exit(0); <br />
}<br />
<br />
}<br />
}<br />
<br />
// Error message dialog<br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
}<br />
<br />
</source><br />
<br />
Now run tha application. Then from the SDCard folder, drag the database file and drop it into your main project, "res" folder.<br />
<br />
===11.3 Add id to Student Class===<br />
Now in our main application project,we need to add id to this class because we are going to preserve our Student objects in database,:<br />
So add a private field and add public getter and setters:<br />
<source lang="java"><br />
<br />
public int getId(){<br />
return this.id;<br />
}<br />
public void setId(int id){<br />
this.id = id;<br />
}<br />
</source><br />
<br />
===11.4 Check for presence of SDCard===<br />
Each time our "Student View" application runs, we have to check for the presence of the SD card, and if it does not exist, we have to show a dialog message.<br />
<br />
Therefore, add the following code to the ViewStudentApp.java class constructor:<br />
<source lang="java"><br />
<br />
public ViewStudentApp() throws Exception {<br />
//This part is from BB Sample application<br />
// Determine if an SDCard is present<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
<br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
// the rest of code goes here<br />
<br />
}<br />
</source><br />
<br />
===11.5 Copy Database File into SDCard===<br />
Now that application knows SDCard is present, It should check if the database file exist, otherwise copy it from the application bundle into SDCard:<br />
<source lang="java"><br />
else<br />
{<br />
String dbLocation = "/SDCard/databases/StudentsList/";<br />
<br />
// Create URI <br />
uri = URI.create(dbLocation + DB_NAME); <br />
<br />
// Open or create a plain text database. This will create the<br />
// directory and file defined by the URI (if they do not already exist).<br />
db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false)); <br />
<br />
// Close the database in case it is blank and we need to write to the file<br />
db.close();<br />
<br />
// Open a connection to the database file <br />
FileConnection fileConnection = (FileConnection)Connector.open("file://" + dbLocation + DB_NAME); <br />
<br />
// If the file is blank, copy the pre-defined database from this<br />
// module to the SDCard.<br />
if(fileConnection.exists() && fileConnection.fileSize() == 0)<br />
{ <br />
readAndWriteDatabaseFile(fileConnection); <br />
} <br />
// here goes the rest of the constructor code<br />
_studentList = new StudentList(db, uri);<br />
</source><br />
<br />
Then add the following method (readAndWriteDatabaseFile) to the file that actually reads the database file and puts it into the simulator:<br />
<source lang="java"><br />
public void readAndWriteDatabaseFile(FileConnection fileConnection) throws IOException<br />
{ <br />
OutputStream outputStream = null;<br />
InputStream inputStream = null; <br />
<br />
// Open an input stream to the pre-defined encrypted database bundled<br />
// within this module.<br />
inputStream = getClass().getResourceAsStream("/" + DB_NAME);<br />
<br />
// Open an output stream to the newly created file<br />
outputStream = (OutputStream)fileConnection.openOutputStream(); <br />
<br />
// Read data from the input stream and write the data to the<br />
// output stream. <br />
byte[] data = new byte[256];<br />
int length = 0;<br />
while (-1 != (length = inputStream.read(data)))<br />
{<br />
outputStream.write(data, 0, length); <br />
} <br />
<br />
// Close the connections<br />
if(fileConnection != null)<br />
{<br />
fileConnection.close();<br />
}<br />
if(outputStream != null)<br />
{<br />
outputStream.close();<br />
}<br />
if(inputStream != null)<br />
{<br />
inputStream.close();<br />
} <br />
}<br />
<br />
</source><br />
<br />
===11.6 Create SQLiteManager Class===<br />
<br />
Now we need a class that will be the only class interacting with our database. It will take a Database object and a URI object to open database in the constructor. It will have methods to perform all the queries we need and at the end of each query will close the database. <br/><br />
<br />
So, create a class called: SQLiteManager, with 2 private fields, and a constructor that sets them and then tries to open database:<br />
<source lang="java"><br />
<br />
package cs.ecl.team1.project;<br />
<br />
<br />
<br />
import java.util.Vector;<br />
import net.rim.device.api.database.Cursor;<br />
import net.rim.device.api.database.DataTypeException;<br />
import net.rim.device.api.database.Database;<br />
import net.rim.device.api.database.DatabaseException;<br />
import net.rim.device.api.database.DatabaseFactory;<br />
import net.rim.device.api.database.Row;<br />
import net.rim.device.api.database.Statement;<br />
import net.rim.device.api.io.URI;<br />
import net.rim.device.api.ui.UiApplication;<br />
import net.rim.device.api.ui.component.Dialog;<br />
<br />
public class SQLManager {<br />
<br />
private static Database db;<br />
private URI uri;<br />
<br />
public SQLManager(Database db, URI uri)<br />
{<br />
this.uri = uri;<br />
this.db = db;<br />
openDB();<br />
}<br />
<br />
}<br />
</source><br />
'''11.6.1 Open Database'''<br/><br />
Then we implement the openDB() method:<br />
<source lang="java"><br />
void openDB()<br />
{ <br />
try<br />
{ <br />
this.db = DatabaseFactory.open(uri);<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
} <br />
</source><br />
'''11.6.2 Close Database'''<br/><br />
Then we definitely need a closeDB() method to use later:<br />
<source lang="java"><br />
static void closeDB()<br />
{ <br />
try<br />
{ <br />
db.close();<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
} <br />
</source><br />
And as you noticed above, we are going to need a method called errorDialog():<br />
<source lang="java"><br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
</source><br />
'''11.6.3 Insert New Student'''<br/><br />
The first query we need is a query that enables us add a new Student, so we need to implement a method for that:<br />
<source lang="java"><br />
//ADD STUDENT<br />
Student addStudent(String fName, String lName, String email, String address){<br />
Student student = null;<br />
try<br />
{<br />
<br />
<br />
Statement statement = db.createStatement("INSERT INTO Student VALUES(NULL,?,?,?,?)"); <br />
statement.prepare(); <br />
<br />
statement.bind(1,fName);<br />
statement.bind(2, lName);<br />
statement.bind(3, email);<br />
statement.bind(4, address);<br />
<br />
statement.execute();<br />
statement.close();<br />
<br />
statement = db.createStatement("SELECT id FROM Student WHERE firstName = ? AND lastName = ?");<br />
statement.prepare();<br />
statement.bind(1, fName); <br />
statement.bind(2, lName);<br />
Cursor cursor = statement.getCursor(); <br />
if(cursor.next())<br />
{<br />
Row row = cursor.getRow();<br />
int id = row.getInteger(0); <br />
student = new Student(id, fName, lName, email, address); <br />
} <br />
cursor.close();<br />
statement.close();<br />
}catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
} <br />
catch(DataTypeException dte)<br />
{<br />
errorDialog(dte.toString());<br />
}<br />
<br />
return student;<br />
}<br />
</source><br />
<br />
'''11.6.4 Delete Student'''<br/><br />
<source lang="java"><br />
<br />
</source><br />
'''11.6.5 Update Student'''<br/><br />
<source lang="java"><br />
<br />
</source><br />
<br />
'''11.6.6 Select All Students'''<br/><br />
gives us the list of all Students<br />
<source lang="java"><br />
<br />
</source><br />
<br />
===11.7 Modify StudentsList Class to use SQLiteManager===<br />
11.7.1 Load list<br/><br />
11.7.2 Add Student<br/><br />
11.7.3 Edit Student<br/><br />
11.7.4 Delete Student<br/><br />
<br />
===11.8 Student View Application in Action===</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62366Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-12T04:02:05Z<p>Ladanzahir: /* 11.6 Create SQLiteManager Class */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Add SDCard to Simulator===<br />
To be able to have data preserved on database, first we need to make sure that simulator can simulate SDCard, so that we can run our application with database. For this purpose first create a folder on your file system. Then run the simulator and from the top menu choose: Simulate > Change SD Card... .<br/><br />
Then Mount Directory, and select the folder you just created. Every time you restart the simulator, before running the app you need to make sure that the folder is mounted as SD Card. later on you will see that the database file gets created there.<br/><br />
[[Image: BB_SDCard.png | 350px]]<br/><br />
<br />
===11.2 Create Database File===<br />
We would like to create a database file including out Student Entity, so that we can put it in the project. Then every time the app runs, first it checks if it is the first time run of the app on the device or simulator. If so, the app will copy the file in to the SDCard. Next time that you run the application, it will know that the file is there, so will not override it. <Br/><br />
<br />
For this purpose, create a simple blackberry project with only the application object. We do not need any screen here. call it "DBCreator".<br />
and this will need to only have a class called MyApp.java which extends UIApplication. Here is the code for this class:<br />
<br />
<source lang="java" ><br />
<br />
package mypackage;<br />
<br />
import java.util.Enumeration;<br />
import javax.microedition.io.file.FileSystemRegistry;<br />
import net.rim.device.api.ui.*;<br />
import net.rim.device.api.ui.component.*;<br />
import net.rim.device.api.database.*;<br />
import net.rim.device.api.io.*;<br />
<br />
/**<br />
* This class extends the UiApplication class, providing a<br />
* graphical user interface.<br />
*/<br />
public class MyApp extends UiApplication<br />
{<br />
private static String DB_NAME = "SQLiteStudentList";<br />
<br />
/**<br />
* Entry point for application<br />
* @param args Command line arguments (not used)<br />
*/<br />
public static void main(String[] args) throws Exception<br />
{<br />
// Create a new instance of the application and make the currently<br />
// running thread the application's event dispatch thread.<br />
MyApp theApp = new MyApp(); <br />
theApp.enterEventDispatcher();<br />
}<br />
<br />
<br />
/**<br />
* Creates a new MyApp object<br />
*/<br />
public MyApp()throws Exception<br />
{ <br />
// Check for the presence of the SDCard<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
try{<br />
// create a URI object with te file name and location <br />
String dbLocation = "/SDCard/databases/DBCreator/";<br />
URI uri = URI.create(dbLocation + DB_NAME);<br />
<br />
// open a database connection to that URI<br />
Database db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false));<br />
<br />
// create the table if it does not already exist<br />
Statement statement =<br />
db.createStatement("CREATE TABLE IF NOT EXISTS Student(id INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT, email TEXT, address TEXT)");<br />
statement.prepare();<br />
<br />
//execute the statement<br />
statement.execute();<br />
<br />
// close statement and database<br />
statement.close(); <br />
db.close(); <br />
<br />
}catch(Exception ex ) {<br />
errorDialog(ex.getMessage());<br />
System.exit(0); <br />
}<br />
<br />
}<br />
}<br />
<br />
// Error message dialog<br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
}<br />
<br />
</source><br />
<br />
Now run tha application. Then from the SDCard folder, drag the database file and drop it into your main project, "res" folder.<br />
<br />
===11.3 Add id to Student Class===<br />
Now in our main application project,we need to add id to this class because we are going to preserve our Student objects in database,:<br />
So add a private field and add public getter and setters:<br />
<source lang="java"><br />
<br />
public int getId(){<br />
return this.id;<br />
}<br />
public void setId(int id){<br />
this.id = id;<br />
}<br />
</source><br />
<br />
===11.4 Check for presence of SDCard===<br />
Each time our "Student View" application runs, we have to check for the presence of the SD card, and if it does not exist, we have to show a dialog message.<br />
<br />
Therefore, add the following code to the ViewStudentApp.java class constructor:<br />
<source lang="java"><br />
<br />
public ViewStudentApp() throws Exception {<br />
//This part is from BB Sample application<br />
// Determine if an SDCard is present<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
<br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
// the rest of code goes here<br />
<br />
}<br />
</source><br />
<br />
===11.5 Copy Database File into SDCard===<br />
Now that application knows SDCard is present, It should check if the database file exist, otherwise copy it from the application bundle into SDCard:<br />
<source lang="java"><br />
else<br />
{<br />
String dbLocation = "/SDCard/databases/StudentsList/";<br />
<br />
// Create URI <br />
uri = URI.create(dbLocation + DB_NAME); <br />
<br />
// Open or create a plain text database. This will create the<br />
// directory and file defined by the URI (if they do not already exist).<br />
db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false)); <br />
<br />
// Close the database in case it is blank and we need to write to the file<br />
db.close();<br />
<br />
// Open a connection to the database file <br />
FileConnection fileConnection = (FileConnection)Connector.open("file://" + dbLocation + DB_NAME); <br />
<br />
// If the file is blank, copy the pre-defined database from this<br />
// module to the SDCard.<br />
if(fileConnection.exists() && fileConnection.fileSize() == 0)<br />
{ <br />
readAndWriteDatabaseFile(fileConnection); <br />
} <br />
// here goes the rest of the constructor code<br />
_studentList = new StudentList(db, uri);<br />
</source><br />
<br />
Then add the following method (readAndWriteDatabaseFile) to the file that actually reads the database file and puts it into the simulator:<br />
<source lang="java"><br />
public void readAndWriteDatabaseFile(FileConnection fileConnection) throws IOException<br />
{ <br />
OutputStream outputStream = null;<br />
InputStream inputStream = null; <br />
<br />
// Open an input stream to the pre-defined encrypted database bundled<br />
// within this module.<br />
inputStream = getClass().getResourceAsStream("/" + DB_NAME);<br />
<br />
// Open an output stream to the newly created file<br />
outputStream = (OutputStream)fileConnection.openOutputStream(); <br />
<br />
// Read data from the input stream and write the data to the<br />
// output stream. <br />
byte[] data = new byte[256];<br />
int length = 0;<br />
while (-1 != (length = inputStream.read(data)))<br />
{<br />
outputStream.write(data, 0, length); <br />
} <br />
<br />
// Close the connections<br />
if(fileConnection != null)<br />
{<br />
fileConnection.close();<br />
}<br />
if(outputStream != null)<br />
{<br />
outputStream.close();<br />
}<br />
if(inputStream != null)<br />
{<br />
inputStream.close();<br />
} <br />
}<br />
<br />
</source><br />
<br />
===11.6 Create SQLiteManager Class===<br />
<br />
Now we need a class that will be the only class interacting with our database. It will take a Database object and a URI object to open database in the constructor. It will have methods to perform all the queries we need and at the end of each query will close the database. <br/><br />
<br />
So, create a class called: SQLiteManager, with 2 private fields, and a constructor that sets them and then tries to open database:<br />
<source lang="java"><br />
<br />
package cs.ecl.team1.project;<br />
<br />
<br />
<br />
import java.util.Vector;<br />
import net.rim.device.api.database.Cursor;<br />
import net.rim.device.api.database.DataTypeException;<br />
import net.rim.device.api.database.Database;<br />
import net.rim.device.api.database.DatabaseException;<br />
import net.rim.device.api.database.DatabaseFactory;<br />
import net.rim.device.api.database.Row;<br />
import net.rim.device.api.database.Statement;<br />
import net.rim.device.api.io.URI;<br />
import net.rim.device.api.ui.UiApplication;<br />
import net.rim.device.api.ui.component.Dialog;<br />
<br />
public class SQLManager {<br />
<br />
private static Database db;<br />
private URI uri;<br />
<br />
public SQLManager(Database db, URI uri)<br />
{<br />
this.uri = uri;<br />
this.db = db;<br />
openDB();<br />
}<br />
<br />
}<br />
</source><br />
11.6.1 '''Open Database'''<br/><br />
Then we implement the opemDB() method:<br />
<source lang="java"><br />
void openDB()<br />
{ <br />
try<br />
{ <br />
this.db = DatabaseFactory.open(uri);<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
} <br />
</source><br />
11.6.2 '''Close Database'''<br/><br />
Then we definitely need a closeDB() method to use later:<br />
<source lang="java"><br />
static void closeDB()<br />
{ <br />
try<br />
{ <br />
db.close();<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
} <br />
</source><br />
And as you noticed above, we are going to need a method called errorDialog():<br />
<source lang="java"><br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
</source><br />
11.6.3 '''Insert New Student'''<br/><br />
The first query we need is a query that enables us add a new Student, so we need to implement a method for that:<br />
<br />
<source lang="java"><br />
<br />
</source><br />
<br />
11.6.4 '''Delete Student'''<br/><br />
<source lang="java"><br />
<br />
</source><br />
11.6.5 '''Update Student'''<br/><br />
<source lang="java"><br />
<br />
</source><br />
<br />
11.6.6 '''Select All Students'''<br/><br />
gives us the list of all Students<br />
<source lang="java"><br />
<br />
</source><br />
<br />
===11.7 Modify StudentsList Class to use SQLiteManager===<br />
11.7.1 Load list<br/><br />
11.7.2 Add Student<br/><br />
11.7.3 Edit Student<br/><br />
11.7.4 Delete Student<br/><br />
<br />
===11.8 Student View Application in Action===</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62365Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-12T04:00:09Z<p>Ladanzahir: /* 11.6 Create SQLiteManager Class */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Add SDCard to Simulator===<br />
To be able to have data preserved on database, first we need to make sure that simulator can simulate SDCard, so that we can run our application with database. For this purpose first create a folder on your file system. Then run the simulator and from the top menu choose: Simulate > Change SD Card... .<br/><br />
Then Mount Directory, and select the folder you just created. Every time you restart the simulator, before running the app you need to make sure that the folder is mounted as SD Card. later on you will see that the database file gets created there.<br/><br />
[[Image: BB_SDCard.png | 350px]]<br/><br />
<br />
===11.2 Create Database File===<br />
We would like to create a database file including out Student Entity, so that we can put it in the project. Then every time the app runs, first it checks if it is the first time run of the app on the device or simulator. If so, the app will copy the file in to the SDCard. Next time that you run the application, it will know that the file is there, so will not override it. <Br/><br />
<br />
For this purpose, create a simple blackberry project with only the application object. We do not need any screen here. call it "DBCreator".<br />
and this will need to only have a class called MyApp.java which extends UIApplication. Here is the code for this class:<br />
<br />
<source lang="java" ><br />
<br />
package mypackage;<br />
<br />
import java.util.Enumeration;<br />
import javax.microedition.io.file.FileSystemRegistry;<br />
import net.rim.device.api.ui.*;<br />
import net.rim.device.api.ui.component.*;<br />
import net.rim.device.api.database.*;<br />
import net.rim.device.api.io.*;<br />
<br />
/**<br />
* This class extends the UiApplication class, providing a<br />
* graphical user interface.<br />
*/<br />
public class MyApp extends UiApplication<br />
{<br />
private static String DB_NAME = "SQLiteStudentList";<br />
<br />
/**<br />
* Entry point for application<br />
* @param args Command line arguments (not used)<br />
*/<br />
public static void main(String[] args) throws Exception<br />
{<br />
// Create a new instance of the application and make the currently<br />
// running thread the application's event dispatch thread.<br />
MyApp theApp = new MyApp(); <br />
theApp.enterEventDispatcher();<br />
}<br />
<br />
<br />
/**<br />
* Creates a new MyApp object<br />
*/<br />
public MyApp()throws Exception<br />
{ <br />
// Check for the presence of the SDCard<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
try{<br />
// create a URI object with te file name and location <br />
String dbLocation = "/SDCard/databases/DBCreator/";<br />
URI uri = URI.create(dbLocation + DB_NAME);<br />
<br />
// open a database connection to that URI<br />
Database db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false));<br />
<br />
// create the table if it does not already exist<br />
Statement statement =<br />
db.createStatement("CREATE TABLE IF NOT EXISTS Student(id INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT, email TEXT, address TEXT)");<br />
statement.prepare();<br />
<br />
//execute the statement<br />
statement.execute();<br />
<br />
// close statement and database<br />
statement.close(); <br />
db.close(); <br />
<br />
}catch(Exception ex ) {<br />
errorDialog(ex.getMessage());<br />
System.exit(0); <br />
}<br />
<br />
}<br />
}<br />
<br />
// Error message dialog<br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
}<br />
<br />
</source><br />
<br />
Now run tha application. Then from the SDCard folder, drag the database file and drop it into your main project, "res" folder.<br />
<br />
===11.3 Add id to Student Class===<br />
Now in our main application project,we need to add id to this class because we are going to preserve our Student objects in database,:<br />
So add a private field and add public getter and setters:<br />
<source lang="java"><br />
<br />
public int getId(){<br />
return this.id;<br />
}<br />
public void setId(int id){<br />
this.id = id;<br />
}<br />
</source><br />
<br />
===11.4 Check for presence of SDCard===<br />
Each time our "Student View" application runs, we have to check for the presence of the SD card, and if it does not exist, we have to show a dialog message.<br />
<br />
Therefore, add the following code to the ViewStudentApp.java class constructor:<br />
<source lang="java"><br />
<br />
public ViewStudentApp() throws Exception {<br />
//This part is from BB Sample application<br />
// Determine if an SDCard is present<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
<br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
// the rest of code goes here<br />
<br />
}<br />
</source><br />
<br />
===11.5 Copy Database File into SDCard===<br />
Now that application knows SDCard is present, It should check if the database file exist, otherwise copy it from the application bundle into SDCard:<br />
<source lang="java"><br />
else<br />
{<br />
String dbLocation = "/SDCard/databases/StudentsList/";<br />
<br />
// Create URI <br />
uri = URI.create(dbLocation + DB_NAME); <br />
<br />
// Open or create a plain text database. This will create the<br />
// directory and file defined by the URI (if they do not already exist).<br />
db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false)); <br />
<br />
// Close the database in case it is blank and we need to write to the file<br />
db.close();<br />
<br />
// Open a connection to the database file <br />
FileConnection fileConnection = (FileConnection)Connector.open("file://" + dbLocation + DB_NAME); <br />
<br />
// If the file is blank, copy the pre-defined database from this<br />
// module to the SDCard.<br />
if(fileConnection.exists() && fileConnection.fileSize() == 0)<br />
{ <br />
readAndWriteDatabaseFile(fileConnection); <br />
} <br />
// here goes the rest of the constructor code<br />
_studentList = new StudentList(db, uri);<br />
</source><br />
<br />
Then add the following method (readAndWriteDatabaseFile) to the file that actually reads the database file and puts it into the simulator:<br />
<source lang="java"><br />
public void readAndWriteDatabaseFile(FileConnection fileConnection) throws IOException<br />
{ <br />
OutputStream outputStream = null;<br />
InputStream inputStream = null; <br />
<br />
// Open an input stream to the pre-defined encrypted database bundled<br />
// within this module.<br />
inputStream = getClass().getResourceAsStream("/" + DB_NAME);<br />
<br />
// Open an output stream to the newly created file<br />
outputStream = (OutputStream)fileConnection.openOutputStream(); <br />
<br />
// Read data from the input stream and write the data to the<br />
// output stream. <br />
byte[] data = new byte[256];<br />
int length = 0;<br />
while (-1 != (length = inputStream.read(data)))<br />
{<br />
outputStream.write(data, 0, length); <br />
} <br />
<br />
// Close the connections<br />
if(fileConnection != null)<br />
{<br />
fileConnection.close();<br />
}<br />
if(outputStream != null)<br />
{<br />
outputStream.close();<br />
}<br />
if(inputStream != null)<br />
{<br />
inputStream.close();<br />
} <br />
}<br />
<br />
</source><br />
<br />
===11.6 Create SQLiteManager Class===<br />
<br />
Now we need a class that will be the only class interacting with our database. It will take a Database object and a URI object to open database in the constructor. It will have methods to perform all the queries we need and at the end of each query will close the database. <br/><br />
<br />
So, create a class called: SQLiteManager, with 2 private fields, and a constructor that sets them and then tries to open database:<br />
<source lang="java"><br />
<br />
package cs.ecl.team1.project;<br />
<br />
<br />
<br />
import java.util.Vector;<br />
import net.rim.device.api.database.Cursor;<br />
import net.rim.device.api.database.DataTypeException;<br />
import net.rim.device.api.database.Database;<br />
import net.rim.device.api.database.DatabaseException;<br />
import net.rim.device.api.database.DatabaseFactory;<br />
import net.rim.device.api.database.Row;<br />
import net.rim.device.api.database.Statement;<br />
import net.rim.device.api.io.URI;<br />
import net.rim.device.api.ui.UiApplication;<br />
import net.rim.device.api.ui.component.Dialog;<br />
<br />
public class SQLManager {<br />
<br />
private static Database db;<br />
private URI uri;<br />
<br />
public SQLManager(Database db, URI uri)<br />
{<br />
this.uri = uri;<br />
this.db = db;<br />
openDB();<br />
}<br />
<br />
}<br />
</source><br />
11.6.1 Open Database<br/><br />
Then we implement the opemDB() method:<br />
<source lang="java"><br />
void openDB()<br />
{ <br />
try<br />
{ <br />
this.db = DatabaseFactory.open(uri);<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
} <br />
</source><br />
11.6.2 Close Database<br/><br />
Then we definitely need a closeDB() method to use later:<br />
<source lang="java"><br />
static void closeDB()<br />
{ <br />
try<br />
{ <br />
db.close();<br />
}<br />
catch(DatabaseException dbe)<br />
{<br />
errorDialog(dbe.toString());<br />
}<br />
} <br />
</source><br />
And as you noticed above, we are going to need a method called errorDialog():<br />
<source lang="java"><br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
</source><br />
11.6.3 Insert New Student<br/><br />
The first query we need is a query that enables us add a new Student, so we need to implement a method for that:<br />
<br />
<source lang="java"><br />
<br />
</source><br />
11.6.4 Select All Students<br/><br />
gives us the list of all Students<br />
<source lang="java"><br />
<br />
</source><br />
<br />
<br />
11.6.5 Delete Student<br/><br />
<source lang="java"><br />
<br />
</source><br />
11.6.6 Update Student<br/><br />
<source lang="java"><br />
<br />
</source><br />
<br />
===11.7 Modify StudentsList Class to use SQLiteManager===<br />
11.7.1 Load list<br/><br />
11.7.2 Add Student<br/><br />
11.7.3 Edit Student<br/><br />
11.7.4 Delete Student<br/><br />
<br />
===11.8 Student View Application in Action===</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62364Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-12T03:50:58Z<p>Ladanzahir: /* 11.6 Create SQLiteManager Class */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Add SDCard to Simulator===<br />
To be able to have data preserved on database, first we need to make sure that simulator can simulate SDCard, so that we can run our application with database. For this purpose first create a folder on your file system. Then run the simulator and from the top menu choose: Simulate > Change SD Card... .<br/><br />
Then Mount Directory, and select the folder you just created. Every time you restart the simulator, before running the app you need to make sure that the folder is mounted as SD Card. later on you will see that the database file gets created there.<br/><br />
[[Image: BB_SDCard.png | 350px]]<br/><br />
<br />
===11.2 Create Database File===<br />
We would like to create a database file including out Student Entity, so that we can put it in the project. Then every time the app runs, first it checks if it is the first time run of the app on the device or simulator. If so, the app will copy the file in to the SDCard. Next time that you run the application, it will know that the file is there, so will not override it. <Br/><br />
<br />
For this purpose, create a simple blackberry project with only the application object. We do not need any screen here. call it "DBCreator".<br />
and this will need to only have a class called MyApp.java which extends UIApplication. Here is the code for this class:<br />
<br />
<source lang="java" ><br />
<br />
package mypackage;<br />
<br />
import java.util.Enumeration;<br />
import javax.microedition.io.file.FileSystemRegistry;<br />
import net.rim.device.api.ui.*;<br />
import net.rim.device.api.ui.component.*;<br />
import net.rim.device.api.database.*;<br />
import net.rim.device.api.io.*;<br />
<br />
/**<br />
* This class extends the UiApplication class, providing a<br />
* graphical user interface.<br />
*/<br />
public class MyApp extends UiApplication<br />
{<br />
private static String DB_NAME = "SQLiteStudentList";<br />
<br />
/**<br />
* Entry point for application<br />
* @param args Command line arguments (not used)<br />
*/<br />
public static void main(String[] args) throws Exception<br />
{<br />
// Create a new instance of the application and make the currently<br />
// running thread the application's event dispatch thread.<br />
MyApp theApp = new MyApp(); <br />
theApp.enterEventDispatcher();<br />
}<br />
<br />
<br />
/**<br />
* Creates a new MyApp object<br />
*/<br />
public MyApp()throws Exception<br />
{ <br />
// Check for the presence of the SDCard<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
try{<br />
// create a URI object with te file name and location <br />
String dbLocation = "/SDCard/databases/DBCreator/";<br />
URI uri = URI.create(dbLocation + DB_NAME);<br />
<br />
// open a database connection to that URI<br />
Database db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false));<br />
<br />
// create the table if it does not already exist<br />
Statement statement =<br />
db.createStatement("CREATE TABLE IF NOT EXISTS Student(id INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT, email TEXT, address TEXT)");<br />
statement.prepare();<br />
<br />
//execute the statement<br />
statement.execute();<br />
<br />
// close statement and database<br />
statement.close(); <br />
db.close(); <br />
<br />
}catch(Exception ex ) {<br />
errorDialog(ex.getMessage());<br />
System.exit(0); <br />
}<br />
<br />
}<br />
}<br />
<br />
// Error message dialog<br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
}<br />
<br />
</source><br />
<br />
Now run tha application. Then from the SDCard folder, drag the database file and drop it into your main project, "res" folder.<br />
<br />
===11.3 Add id to Student Class===<br />
Now in our main application project,we need to add id to this class because we are going to preserve our Student objects in database,:<br />
So add a private field and add public getter and setters:<br />
<source lang="java"><br />
<br />
public int getId(){<br />
return this.id;<br />
}<br />
public void setId(int id){<br />
this.id = id;<br />
}<br />
</source><br />
<br />
===11.4 Check for presence of SDCard===<br />
Each time our "Student View" application runs, we have to check for the presence of the SD card, and if it does not exist, we have to show a dialog message.<br />
<br />
Therefore, add the following code to the ViewStudentApp.java class constructor:<br />
<source lang="java"><br />
<br />
public ViewStudentApp() throws Exception {<br />
//This part is from BB Sample application<br />
// Determine if an SDCard is present<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
<br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
// the rest of code goes here<br />
<br />
}<br />
</source><br />
<br />
===11.5 Copy Database File into SDCard===<br />
Now that application knows SDCard is present, It should check if the database file exist, otherwise copy it from the application bundle into SDCard:<br />
<source lang="java"><br />
else<br />
{<br />
String dbLocation = "/SDCard/databases/StudentsList/";<br />
<br />
// Create URI <br />
uri = URI.create(dbLocation + DB_NAME); <br />
<br />
// Open or create a plain text database. This will create the<br />
// directory and file defined by the URI (if they do not already exist).<br />
db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false)); <br />
<br />
// Close the database in case it is blank and we need to write to the file<br />
db.close();<br />
<br />
// Open a connection to the database file <br />
FileConnection fileConnection = (FileConnection)Connector.open("file://" + dbLocation + DB_NAME); <br />
<br />
// If the file is blank, copy the pre-defined database from this<br />
// module to the SDCard.<br />
if(fileConnection.exists() && fileConnection.fileSize() == 0)<br />
{ <br />
readAndWriteDatabaseFile(fileConnection); <br />
} <br />
// here goes the rest of the constructor code<br />
_studentList = new StudentList(db, uri);<br />
</source><br />
<br />
Then add the following method (readAndWriteDatabaseFile) to the file that actually reads the database file and puts it into the simulator:<br />
<source lang="java"><br />
public void readAndWriteDatabaseFile(FileConnection fileConnection) throws IOException<br />
{ <br />
OutputStream outputStream = null;<br />
InputStream inputStream = null; <br />
<br />
// Open an input stream to the pre-defined encrypted database bundled<br />
// within this module.<br />
inputStream = getClass().getResourceAsStream("/" + DB_NAME);<br />
<br />
// Open an output stream to the newly created file<br />
outputStream = (OutputStream)fileConnection.openOutputStream(); <br />
<br />
// Read data from the input stream and write the data to the<br />
// output stream. <br />
byte[] data = new byte[256];<br />
int length = 0;<br />
while (-1 != (length = inputStream.read(data)))<br />
{<br />
outputStream.write(data, 0, length); <br />
} <br />
<br />
// Close the connections<br />
if(fileConnection != null)<br />
{<br />
fileConnection.close();<br />
}<br />
if(outputStream != null)<br />
{<br />
outputStream.close();<br />
}<br />
if(inputStream != null)<br />
{<br />
inputStream.close();<br />
} <br />
}<br />
<br />
</source><br />
<br />
===11.6 Create SQLiteManager Class===<br />
<br />
Now we need a class that will be the only class interacting with our database. It will take a Database object and a URI object to open database in the constructor. It will have methods to perform all the queries we need and at the end of each query will close the database. <br/><br />
<br />
So, create a class called: SQLiteManager, with 2 private fields :<br />
<source lang="java"><br />
<br />
package cs.ecl.team1.project;<br />
<br />
<br />
<br />
import java.util.Vector;<br />
import net.rim.device.api.database.Cursor;<br />
import net.rim.device.api.database.DataTypeException;<br />
import net.rim.device.api.database.Database;<br />
import net.rim.device.api.database.DatabaseException;<br />
import net.rim.device.api.database.DatabaseFactory;<br />
import net.rim.device.api.database.Row;<br />
import net.rim.device.api.database.Statement;<br />
import net.rim.device.api.io.URI;<br />
import net.rim.device.api.ui.UiApplication;<br />
import net.rim.device.api.ui.component.Dialog;<br />
<br />
public class SQLManager {<br />
<br />
private static Database db;<br />
private URI uri;<br />
}<br />
</source><br />
11.6.1 Open Database<br/><br />
11.6.2 Close Database<br/><br />
11.6.3 Select All Students<br/><br />
11.6.4 Insert New Student<br/><br />
11.6.5 Delete Student<br/><br />
11.6.6 Update Student<br/><br />
<br />
===11.7 Modify StudentsList Class to use SQLiteManager===<br />
11.7.1 Load list<br/><br />
11.7.2 Add Student<br/><br />
11.7.3 Edit Student<br/><br />
11.7.4 Delete Student<br/><br />
<br />
===11.8 Student View Application in Action===</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62363Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-12T03:48:41Z<p>Ladanzahir: /* 11.5 Copy Database File into SDCard */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Add SDCard to Simulator===<br />
To be able to have data preserved on database, first we need to make sure that simulator can simulate SDCard, so that we can run our application with database. For this purpose first create a folder on your file system. Then run the simulator and from the top menu choose: Simulate > Change SD Card... .<br/><br />
Then Mount Directory, and select the folder you just created. Every time you restart the simulator, before running the app you need to make sure that the folder is mounted as SD Card. later on you will see that the database file gets created there.<br/><br />
[[Image: BB_SDCard.png | 350px]]<br/><br />
<br />
===11.2 Create Database File===<br />
We would like to create a database file including out Student Entity, so that we can put it in the project. Then every time the app runs, first it checks if it is the first time run of the app on the device or simulator. If so, the app will copy the file in to the SDCard. Next time that you run the application, it will know that the file is there, so will not override it. <Br/><br />
<br />
For this purpose, create a simple blackberry project with only the application object. We do not need any screen here. call it "DBCreator".<br />
and this will need to only have a class called MyApp.java which extends UIApplication. Here is the code for this class:<br />
<br />
<source lang="java" ><br />
<br />
package mypackage;<br />
<br />
import java.util.Enumeration;<br />
import javax.microedition.io.file.FileSystemRegistry;<br />
import net.rim.device.api.ui.*;<br />
import net.rim.device.api.ui.component.*;<br />
import net.rim.device.api.database.*;<br />
import net.rim.device.api.io.*;<br />
<br />
/**<br />
* This class extends the UiApplication class, providing a<br />
* graphical user interface.<br />
*/<br />
public class MyApp extends UiApplication<br />
{<br />
private static String DB_NAME = "SQLiteStudentList";<br />
<br />
/**<br />
* Entry point for application<br />
* @param args Command line arguments (not used)<br />
*/<br />
public static void main(String[] args) throws Exception<br />
{<br />
// Create a new instance of the application and make the currently<br />
// running thread the application's event dispatch thread.<br />
MyApp theApp = new MyApp(); <br />
theApp.enterEventDispatcher();<br />
}<br />
<br />
<br />
/**<br />
* Creates a new MyApp object<br />
*/<br />
public MyApp()throws Exception<br />
{ <br />
// Check for the presence of the SDCard<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
try{<br />
// create a URI object with te file name and location <br />
String dbLocation = "/SDCard/databases/DBCreator/";<br />
URI uri = URI.create(dbLocation + DB_NAME);<br />
<br />
// open a database connection to that URI<br />
Database db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false));<br />
<br />
// create the table if it does not already exist<br />
Statement statement =<br />
db.createStatement("CREATE TABLE IF NOT EXISTS Student(id INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT, email TEXT, address TEXT)");<br />
statement.prepare();<br />
<br />
//execute the statement<br />
statement.execute();<br />
<br />
// close statement and database<br />
statement.close(); <br />
db.close(); <br />
<br />
}catch(Exception ex ) {<br />
errorDialog(ex.getMessage());<br />
System.exit(0); <br />
}<br />
<br />
}<br />
}<br />
<br />
// Error message dialog<br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
}<br />
<br />
</source><br />
<br />
Now run tha application. Then from the SDCard folder, drag the database file and drop it into your main project, "res" folder.<br />
<br />
===11.3 Add id to Student Class===<br />
Now in our main application project,we need to add id to this class because we are going to preserve our Student objects in database,:<br />
So add a private field and add public getter and setters:<br />
<source lang="java"><br />
<br />
public int getId(){<br />
return this.id;<br />
}<br />
public void setId(int id){<br />
this.id = id;<br />
}<br />
</source><br />
<br />
===11.4 Check for presence of SDCard===<br />
Each time our "Student View" application runs, we have to check for the presence of the SD card, and if it does not exist, we have to show a dialog message.<br />
<br />
Therefore, add the following code to the ViewStudentApp.java class constructor:<br />
<source lang="java"><br />
<br />
public ViewStudentApp() throws Exception {<br />
//This part is from BB Sample application<br />
// Determine if an SDCard is present<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
<br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
// the rest of code goes here<br />
<br />
}<br />
</source><br />
<br />
===11.5 Copy Database File into SDCard===<br />
Now that application knows SDCard is present, It should check if the database file exist, otherwise copy it from the application bundle into SDCard:<br />
<source lang="java"><br />
else<br />
{<br />
String dbLocation = "/SDCard/databases/StudentsList/";<br />
<br />
// Create URI <br />
uri = URI.create(dbLocation + DB_NAME); <br />
<br />
// Open or create a plain text database. This will create the<br />
// directory and file defined by the URI (if they do not already exist).<br />
db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false)); <br />
<br />
// Close the database in case it is blank and we need to write to the file<br />
db.close();<br />
<br />
// Open a connection to the database file <br />
FileConnection fileConnection = (FileConnection)Connector.open("file://" + dbLocation + DB_NAME); <br />
<br />
// If the file is blank, copy the pre-defined database from this<br />
// module to the SDCard.<br />
if(fileConnection.exists() && fileConnection.fileSize() == 0)<br />
{ <br />
readAndWriteDatabaseFile(fileConnection); <br />
} <br />
// here goes the rest of the constructor code<br />
_studentList = new StudentList(db, uri);<br />
</source><br />
<br />
Then add the following method (readAndWriteDatabaseFile) to the file that actually reads the database file and puts it into the simulator:<br />
<source lang="java"><br />
public void readAndWriteDatabaseFile(FileConnection fileConnection) throws IOException<br />
{ <br />
OutputStream outputStream = null;<br />
InputStream inputStream = null; <br />
<br />
// Open an input stream to the pre-defined encrypted database bundled<br />
// within this module.<br />
inputStream = getClass().getResourceAsStream("/" + DB_NAME);<br />
<br />
// Open an output stream to the newly created file<br />
outputStream = (OutputStream)fileConnection.openOutputStream(); <br />
<br />
// Read data from the input stream and write the data to the<br />
// output stream. <br />
byte[] data = new byte[256];<br />
int length = 0;<br />
while (-1 != (length = inputStream.read(data)))<br />
{<br />
outputStream.write(data, 0, length); <br />
} <br />
<br />
// Close the connections<br />
if(fileConnection != null)<br />
{<br />
fileConnection.close();<br />
}<br />
if(outputStream != null)<br />
{<br />
outputStream.close();<br />
}<br />
if(inputStream != null)<br />
{<br />
inputStream.close();<br />
} <br />
}<br />
<br />
</source><br />
<br />
===11.6 Create SQLiteManager Class===<br />
<br />
Now we need a class that will be the only class interacting with our database. It will take a Database object and a URI object to open database in the constructor. It will have methods to perform all the queries we need and at the end of each query will close the database. <br/><br />
<br />
So, create a class called: SQLiteManager<br />
11.6.1 Open Database<br/><br />
11.6.2 Close Database<br/><br />
11.6.3 Select All Students<br/><br />
11.6.4 Insert New Student<br/><br />
11.6.5 Delete Student<br/><br />
11.6.6 Update Student<br/><br />
<br />
===11.7 Modify StudentsList Class to use SQLiteManager===<br />
11.7.1 Load list<br/><br />
11.7.2 Add Student<br/><br />
11.7.3 Edit Student<br/><br />
11.7.4 Delete Student<br/><br />
<br />
===11.8 Student View Application in Action===</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62362Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-12T03:47:50Z<p>Ladanzahir: /* 11.5 Copy Database File into SDCard */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Add SDCard to Simulator===<br />
To be able to have data preserved on database, first we need to make sure that simulator can simulate SDCard, so that we can run our application with database. For this purpose first create a folder on your file system. Then run the simulator and from the top menu choose: Simulate > Change SD Card... .<br/><br />
Then Mount Directory, and select the folder you just created. Every time you restart the simulator, before running the app you need to make sure that the folder is mounted as SD Card. later on you will see that the database file gets created there.<br/><br />
[[Image: BB_SDCard.png | 350px]]<br/><br />
<br />
===11.2 Create Database File===<br />
We would like to create a database file including out Student Entity, so that we can put it in the project. Then every time the app runs, first it checks if it is the first time run of the app on the device or simulator. If so, the app will copy the file in to the SDCard. Next time that you run the application, it will know that the file is there, so will not override it. <Br/><br />
<br />
For this purpose, create a simple blackberry project with only the application object. We do not need any screen here. call it "DBCreator".<br />
and this will need to only have a class called MyApp.java which extends UIApplication. Here is the code for this class:<br />
<br />
<source lang="java" ><br />
<br />
package mypackage;<br />
<br />
import java.util.Enumeration;<br />
import javax.microedition.io.file.FileSystemRegistry;<br />
import net.rim.device.api.ui.*;<br />
import net.rim.device.api.ui.component.*;<br />
import net.rim.device.api.database.*;<br />
import net.rim.device.api.io.*;<br />
<br />
/**<br />
* This class extends the UiApplication class, providing a<br />
* graphical user interface.<br />
*/<br />
public class MyApp extends UiApplication<br />
{<br />
private static String DB_NAME = "SQLiteStudentList";<br />
<br />
/**<br />
* Entry point for application<br />
* @param args Command line arguments (not used)<br />
*/<br />
public static void main(String[] args) throws Exception<br />
{<br />
// Create a new instance of the application and make the currently<br />
// running thread the application's event dispatch thread.<br />
MyApp theApp = new MyApp(); <br />
theApp.enterEventDispatcher();<br />
}<br />
<br />
<br />
/**<br />
* Creates a new MyApp object<br />
*/<br />
public MyApp()throws Exception<br />
{ <br />
// Check for the presence of the SDCard<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
try{<br />
// create a URI object with te file name and location <br />
String dbLocation = "/SDCard/databases/DBCreator/";<br />
URI uri = URI.create(dbLocation + DB_NAME);<br />
<br />
// open a database connection to that URI<br />
Database db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false));<br />
<br />
// create the table if it does not already exist<br />
Statement statement =<br />
db.createStatement("CREATE TABLE IF NOT EXISTS Student(id INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT, email TEXT, address TEXT)");<br />
statement.prepare();<br />
<br />
//execute the statement<br />
statement.execute();<br />
<br />
// close statement and database<br />
statement.close(); <br />
db.close(); <br />
<br />
}catch(Exception ex ) {<br />
errorDialog(ex.getMessage());<br />
System.exit(0); <br />
}<br />
<br />
}<br />
}<br />
<br />
// Error message dialog<br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
}<br />
<br />
</source><br />
<br />
Now run tha application. Then from the SDCard folder, drag the database file and drop it into your main project, "res" folder.<br />
<br />
===11.3 Add id to Student Class===<br />
Now in our main application project,we need to add id to this class because we are going to preserve our Student objects in database,:<br />
So add a private field and add public getter and setters:<br />
<source lang="java"><br />
<br />
public int getId(){<br />
return this.id;<br />
}<br />
public void setId(int id){<br />
this.id = id;<br />
}<br />
</source><br />
<br />
===11.4 Check for presence of SDCard===<br />
Each time our "Student View" application runs, we have to check for the presence of the SD card, and if it does not exist, we have to show a dialog message.<br />
<br />
Therefore, add the following code to the ViewStudentApp.java class constructor:<br />
<source lang="java"><br />
<br />
public ViewStudentApp() throws Exception {<br />
//This part is from BB Sample application<br />
// Determine if an SDCard is present<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
<br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
// the rest of code goes here<br />
<br />
}<br />
</source><br />
<br />
===11.5 Copy Database File into SDCard===<br />
Now that application knows SDCard is present, It should check if the database file exist, otherwise copy it from the application bundle into SDCard:<br />
<source lang="java"><br />
else<br />
{<br />
String dbLocation = "/SDCard/databases/StudentsList/";<br />
<br />
// Create URI <br />
uri = URI.create(dbLocation + DB_NAME); <br />
<br />
// Open or create a plain text database. This will create the<br />
// directory and file defined by the URI (if they do not already exist).<br />
db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false)); <br />
<br />
// Close the database in case it is blank and we need to write to the file<br />
db.close();<br />
<br />
// Open a connection to the database file <br />
FileConnection fileConnection = (FileConnection)Connector.open("file://" + dbLocation + DB_NAME); <br />
<br />
// If the file is blank, copy the pre-defined database from this<br />
// module to the SDCard.<br />
if(fileConnection.exists() && fileConnection.fileSize() == 0)<br />
{ <br />
readAndWriteDatabaseFile(fileConnection); <br />
} <br />
// here goes the rest of the constructor code<br />
_studentList = new StudentList(db, uri);<br />
</source><br />
<br />
Then add the following method (readAndWriteDatabaseFile) to the file that actually reads the database file and puts it into the simulator:<br />
<sourse lang="java"><br />
public void readAndWriteDatabaseFile(FileConnection fileConnection) throws IOException<br />
{ <br />
OutputStream outputStream = null;<br />
InputStream inputStream = null; <br />
<br />
// Open an input stream to the pre-defined encrypted database bundled<br />
// within this module.<br />
inputStream = getClass().getResourceAsStream("/" + DB_NAME);<br />
<br />
// Open an output stream to the newly created file<br />
outputStream = (OutputStream)fileConnection.openOutputStream(); <br />
<br />
// Read data from the input stream and write the data to the<br />
// output stream. <br />
byte[] data = new byte[256];<br />
int length = 0;<br />
while (-1 != (length = inputStream.read(data)))<br />
{<br />
outputStream.write(data, 0, length); <br />
} <br />
<br />
// Close the connections<br />
if(fileConnection != null)<br />
{<br />
fileConnection.close();<br />
}<br />
if(outputStream != null)<br />
{<br />
outputStream.close();<br />
}<br />
if(inputStream != null)<br />
{<br />
inputStream.close();<br />
} <br />
}<br />
<br />
</source><br />
<br />
===11.6 Create SQLiteManager Class===<br />
<br />
Now we need a class that will be the only class interacting with our database. It will take a Database object and a URI object to open database in the constructor. It will have methods to perform all the queries we need and at the end of each query will close the database. <br/><br />
<br />
So, create a class called: SQLiteManager<br />
11.6.1 Open Database<br/><br />
11.6.2 Close Database<br/><br />
11.6.3 Select All Students<br/><br />
11.6.4 Insert New Student<br/><br />
11.6.5 Delete Student<br/><br />
11.6.6 Update Student<br/><br />
<br />
===11.7 Modify StudentsList Class to use SQLiteManager===<br />
11.7.1 Load list<br/><br />
11.7.2 Add Student<br/><br />
11.7.3 Edit Student<br/><br />
11.7.4 Delete Student<br/><br />
<br />
===11.8 Student View Application in Action===</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62361Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-12T03:46:07Z<p>Ladanzahir: /* 11.6 Create SQLiteManager Class */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Add SDCard to Simulator===<br />
To be able to have data preserved on database, first we need to make sure that simulator can simulate SDCard, so that we can run our application with database. For this purpose first create a folder on your file system. Then run the simulator and from the top menu choose: Simulate > Change SD Card... .<br/><br />
Then Mount Directory, and select the folder you just created. Every time you restart the simulator, before running the app you need to make sure that the folder is mounted as SD Card. later on you will see that the database file gets created there.<br/><br />
[[Image: BB_SDCard.png | 350px]]<br/><br />
<br />
===11.2 Create Database File===<br />
We would like to create a database file including out Student Entity, so that we can put it in the project. Then every time the app runs, first it checks if it is the first time run of the app on the device or simulator. If so, the app will copy the file in to the SDCard. Next time that you run the application, it will know that the file is there, so will not override it. <Br/><br />
<br />
For this purpose, create a simple blackberry project with only the application object. We do not need any screen here. call it "DBCreator".<br />
and this will need to only have a class called MyApp.java which extends UIApplication. Here is the code for this class:<br />
<br />
<source lang="java" ><br />
<br />
package mypackage;<br />
<br />
import java.util.Enumeration;<br />
import javax.microedition.io.file.FileSystemRegistry;<br />
import net.rim.device.api.ui.*;<br />
import net.rim.device.api.ui.component.*;<br />
import net.rim.device.api.database.*;<br />
import net.rim.device.api.io.*;<br />
<br />
/**<br />
* This class extends the UiApplication class, providing a<br />
* graphical user interface.<br />
*/<br />
public class MyApp extends UiApplication<br />
{<br />
private static String DB_NAME = "SQLiteStudentList";<br />
<br />
/**<br />
* Entry point for application<br />
* @param args Command line arguments (not used)<br />
*/<br />
public static void main(String[] args) throws Exception<br />
{<br />
// Create a new instance of the application and make the currently<br />
// running thread the application's event dispatch thread.<br />
MyApp theApp = new MyApp(); <br />
theApp.enterEventDispatcher();<br />
}<br />
<br />
<br />
/**<br />
* Creates a new MyApp object<br />
*/<br />
public MyApp()throws Exception<br />
{ <br />
// Check for the presence of the SDCard<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
try{<br />
// create a URI object with te file name and location <br />
String dbLocation = "/SDCard/databases/DBCreator/";<br />
URI uri = URI.create(dbLocation + DB_NAME);<br />
<br />
// open a database connection to that URI<br />
Database db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false));<br />
<br />
// create the table if it does not already exist<br />
Statement statement =<br />
db.createStatement("CREATE TABLE IF NOT EXISTS Student(id INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT, email TEXT, address TEXT)");<br />
statement.prepare();<br />
<br />
//execute the statement<br />
statement.execute();<br />
<br />
// close statement and database<br />
statement.close(); <br />
db.close(); <br />
<br />
}catch(Exception ex ) {<br />
errorDialog(ex.getMessage());<br />
System.exit(0); <br />
}<br />
<br />
}<br />
}<br />
<br />
// Error message dialog<br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
}<br />
<br />
</source><br />
<br />
Now run tha application. Then from the SDCard folder, drag the database file and drop it into your main project, "res" folder.<br />
<br />
===11.3 Add id to Student Class===<br />
Now in our main application project,we need to add id to this class because we are going to preserve our Student objects in database,:<br />
So add a private field and add public getter and setters:<br />
<source lang="java"><br />
<br />
public int getId(){<br />
return this.id;<br />
}<br />
public void setId(int id){<br />
this.id = id;<br />
}<br />
</source><br />
<br />
===11.4 Check for presence of SDCard===<br />
Each time our "Student View" application runs, we have to check for the presence of the SD card, and if it does not exist, we have to show a dialog message.<br />
<br />
Therefore, add the following code to the ViewStudentApp.java class constructor:<br />
<source lang="java"><br />
<br />
public ViewStudentApp() throws Exception {<br />
//This part is from BB Sample application<br />
// Determine if an SDCard is present<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
<br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
// the rest of code goes here<br />
<br />
}<br />
</source><br />
<br />
===11.5 Copy Database File into SDCard===<br />
Now that application knows SDCard is present, It should check if the database file exist, otherwise copy it from the application bundle into SDCard:<br />
<source lang="java"><br />
else<br />
{<br />
String dbLocation = "/SDCard/databases/StudentsList/";<br />
<br />
// Create URI <br />
uri = URI.create(dbLocation + DB_NAME); <br />
<br />
// Open or create a plain text database. This will create the<br />
// directory and file defined by the URI (if they do not already exist).<br />
db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false)); <br />
<br />
// Close the database in case it is blank and we need to write to the file<br />
db.close();<br />
<br />
// Open a connection to the database file <br />
FileConnection fileConnection = (FileConnection)Connector.open("file://" + dbLocation + DB_NAME); <br />
<br />
// If the file is blank, copy the pre-defined database from this<br />
// module to the SDCard.<br />
if(fileConnection.exists() && fileConnection.fileSize() == 0)<br />
{ <br />
readAndWriteDatabaseFile(fileConnection); <br />
} <br />
// here goes the rest of the constructor code<br />
_studentList = new StudentList(db, uri);<br />
</source><br />
<br />
===11.6 Create SQLiteManager Class===<br />
<br />
Now we need a class that will be the only class interacting with our database. It will take a Database object and a URI object to open database in the constructor. It will have methods to perform all the queries we need and at the end of each query will close the database. <br/><br />
<br />
So, create a class called: SQLiteManager<br />
11.6.1 Open Database<br/><br />
11.6.2 Close Database<br/><br />
11.6.3 Select All Students<br/><br />
11.6.4 Insert New Student<br/><br />
11.6.5 Delete Student<br/><br />
11.6.6 Update Student<br/><br />
<br />
===11.7 Modify StudentsList Class to use SQLiteManager===<br />
11.7.1 Load list<br/><br />
11.7.2 Add Student<br/><br />
11.7.3 Edit Student<br/><br />
11.7.4 Delete Student<br/><br />
<br />
===11.8 Student View Application in Action===</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62360Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-12T03:17:13Z<p>Ladanzahir: /* 11.5 Copy Database File into SDCard */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Add SDCard to Simulator===<br />
To be able to have data preserved on database, first we need to make sure that simulator can simulate SDCard, so that we can run our application with database. For this purpose first create a folder on your file system. Then run the simulator and from the top menu choose: Simulate > Change SD Card... .<br/><br />
Then Mount Directory, and select the folder you just created. Every time you restart the simulator, before running the app you need to make sure that the folder is mounted as SD Card. later on you will see that the database file gets created there.<br/><br />
[[Image: BB_SDCard.png | 350px]]<br/><br />
<br />
===11.2 Create Database File===<br />
We would like to create a database file including out Student Entity, so that we can put it in the project. Then every time the app runs, first it checks if it is the first time run of the app on the device or simulator. If so, the app will copy the file in to the SDCard. Next time that you run the application, it will know that the file is there, so will not override it. <Br/><br />
<br />
For this purpose, create a simple blackberry project with only the application object. We do not need any screen here. call it "DBCreator".<br />
and this will need to only have a class called MyApp.java which extends UIApplication. Here is the code for this class:<br />
<br />
<source lang="java" ><br />
<br />
package mypackage;<br />
<br />
import java.util.Enumeration;<br />
import javax.microedition.io.file.FileSystemRegistry;<br />
import net.rim.device.api.ui.*;<br />
import net.rim.device.api.ui.component.*;<br />
import net.rim.device.api.database.*;<br />
import net.rim.device.api.io.*;<br />
<br />
/**<br />
* This class extends the UiApplication class, providing a<br />
* graphical user interface.<br />
*/<br />
public class MyApp extends UiApplication<br />
{<br />
private static String DB_NAME = "SQLiteStudentList";<br />
<br />
/**<br />
* Entry point for application<br />
* @param args Command line arguments (not used)<br />
*/<br />
public static void main(String[] args) throws Exception<br />
{<br />
// Create a new instance of the application and make the currently<br />
// running thread the application's event dispatch thread.<br />
MyApp theApp = new MyApp(); <br />
theApp.enterEventDispatcher();<br />
}<br />
<br />
<br />
/**<br />
* Creates a new MyApp object<br />
*/<br />
public MyApp()throws Exception<br />
{ <br />
// Check for the presence of the SDCard<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
try{<br />
// create a URI object with te file name and location <br />
String dbLocation = "/SDCard/databases/DBCreator/";<br />
URI uri = URI.create(dbLocation + DB_NAME);<br />
<br />
// open a database connection to that URI<br />
Database db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false));<br />
<br />
// create the table if it does not already exist<br />
Statement statement =<br />
db.createStatement("CREATE TABLE IF NOT EXISTS Student(id INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT, email TEXT, address TEXT)");<br />
statement.prepare();<br />
<br />
//execute the statement<br />
statement.execute();<br />
<br />
// close statement and database<br />
statement.close(); <br />
db.close(); <br />
<br />
}catch(Exception ex ) {<br />
errorDialog(ex.getMessage());<br />
System.exit(0); <br />
}<br />
<br />
}<br />
}<br />
<br />
// Error message dialog<br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
}<br />
<br />
</source><br />
<br />
Now run tha application. Then from the SDCard folder, drag the database file and drop it into your main project, "res" folder.<br />
<br />
===11.3 Add id to Student Class===<br />
Now in our main application project,we need to add id to this class because we are going to preserve our Student objects in database,:<br />
So add a private field and add public getter and setters:<br />
<source lang="java"><br />
<br />
public int getId(){<br />
return this.id;<br />
}<br />
public void setId(int id){<br />
this.id = id;<br />
}<br />
</source><br />
<br />
===11.4 Check for presence of SDCard===<br />
Each time our "Student View" application runs, we have to check for the presence of the SD card, and if it does not exist, we have to show a dialog message.<br />
<br />
Therefore, add the following code to the ViewStudentApp.java class constructor:<br />
<source lang="java"><br />
<br />
public ViewStudentApp() throws Exception {<br />
//This part is from BB Sample application<br />
// Determine if an SDCard is present<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
<br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
// the rest of code goes here<br />
<br />
}<br />
</source><br />
<br />
===11.5 Copy Database File into SDCard===<br />
Now that application knows SDCard is present, It should check if the database file exist, otherwise copy it from the application bundle into SDCard:<br />
<source lang="java"><br />
else<br />
{<br />
String dbLocation = "/SDCard/databases/StudentsList/";<br />
<br />
// Create URI <br />
uri = URI.create(dbLocation + DB_NAME); <br />
<br />
// Open or create a plain text database. This will create the<br />
// directory and file defined by the URI (if they do not already exist).<br />
db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false)); <br />
<br />
// Close the database in case it is blank and we need to write to the file<br />
db.close();<br />
<br />
// Open a connection to the database file <br />
FileConnection fileConnection = (FileConnection)Connector.open("file://" + dbLocation + DB_NAME); <br />
<br />
// If the file is blank, copy the pre-defined database from this<br />
// module to the SDCard.<br />
if(fileConnection.exists() && fileConnection.fileSize() == 0)<br />
{ <br />
readAndWriteDatabaseFile(fileConnection); <br />
} <br />
// here goes the rest of the constructor code<br />
_studentList = new StudentList(db, uri);<br />
</source><br />
<br />
===11.6 Create SQLiteManager Class===<br />
11.6.1 Open Database<br/><br />
11.6.2 Close Database<br/><br />
11.6.3 Select All Students<br/><br />
11.6.4 Insert New Student<br/><br />
11.6.5 Delete Student<br/><br />
11.6.6 Update Student<br/><br />
<br />
===11.7 Modify StudentsList Class to use SQLiteManager===<br />
11.7.1 Load list<br/><br />
11.7.2 Add Student<br/><br />
11.7.3 Edit Student<br/><br />
11.7.4 Delete Student<br/><br />
<br />
===11.8 Student View Application in Action===</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62359Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-12T02:53:22Z<p>Ladanzahir: /* 11.4 Check for presence of SDCard */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Add SDCard to Simulator===<br />
To be able to have data preserved on database, first we need to make sure that simulator can simulate SDCard, so that we can run our application with database. For this purpose first create a folder on your file system. Then run the simulator and from the top menu choose: Simulate > Change SD Card... .<br/><br />
Then Mount Directory, and select the folder you just created. Every time you restart the simulator, before running the app you need to make sure that the folder is mounted as SD Card. later on you will see that the database file gets created there.<br/><br />
[[Image: BB_SDCard.png | 350px]]<br/><br />
<br />
===11.2 Create Database File===<br />
We would like to create a database file including out Student Entity, so that we can put it in the project. Then every time the app runs, first it checks if it is the first time run of the app on the device or simulator. If so, the app will copy the file in to the SDCard. Next time that you run the application, it will know that the file is there, so will not override it. <Br/><br />
<br />
For this purpose, create a simple blackberry project with only the application object. We do not need any screen here. call it "DBCreator".<br />
and this will need to only have a class called MyApp.java which extends UIApplication. Here is the code for this class:<br />
<br />
<source lang="java" ><br />
<br />
package mypackage;<br />
<br />
import java.util.Enumeration;<br />
import javax.microedition.io.file.FileSystemRegistry;<br />
import net.rim.device.api.ui.*;<br />
import net.rim.device.api.ui.component.*;<br />
import net.rim.device.api.database.*;<br />
import net.rim.device.api.io.*;<br />
<br />
/**<br />
* This class extends the UiApplication class, providing a<br />
* graphical user interface.<br />
*/<br />
public class MyApp extends UiApplication<br />
{<br />
private static String DB_NAME = "SQLiteStudentList";<br />
<br />
/**<br />
* Entry point for application<br />
* @param args Command line arguments (not used)<br />
*/<br />
public static void main(String[] args) throws Exception<br />
{<br />
// Create a new instance of the application and make the currently<br />
// running thread the application's event dispatch thread.<br />
MyApp theApp = new MyApp(); <br />
theApp.enterEventDispatcher();<br />
}<br />
<br />
<br />
/**<br />
* Creates a new MyApp object<br />
*/<br />
public MyApp()throws Exception<br />
{ <br />
// Check for the presence of the SDCard<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
try{<br />
// create a URI object with te file name and location <br />
String dbLocation = "/SDCard/databases/DBCreator/";<br />
URI uri = URI.create(dbLocation + DB_NAME);<br />
<br />
// open a database connection to that URI<br />
Database db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false));<br />
<br />
// create the table if it does not already exist<br />
Statement statement =<br />
db.createStatement("CREATE TABLE IF NOT EXISTS Student(id INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT, email TEXT, address TEXT)");<br />
statement.prepare();<br />
<br />
//execute the statement<br />
statement.execute();<br />
<br />
// close statement and database<br />
statement.close(); <br />
db.close(); <br />
<br />
}catch(Exception ex ) {<br />
errorDialog(ex.getMessage());<br />
System.exit(0); <br />
}<br />
<br />
}<br />
}<br />
<br />
// Error message dialog<br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
}<br />
<br />
</source><br />
<br />
Now run tha application. Then from the SDCard folder, drag the database file and drop it into your main project, "res" folder.<br />
<br />
===11.3 Add id to Student Class===<br />
Now in our main application project,we need to add id to this class because we are going to preserve our Student objects in database,:<br />
So add a private field and add public getter and setters:<br />
<source lang="java"><br />
<br />
public int getId(){<br />
return this.id;<br />
}<br />
public void setId(int id){<br />
this.id = id;<br />
}<br />
</source><br />
<br />
===11.4 Check for presence of SDCard===<br />
Each time our "Student View" application runs, we have to check for the presence of the SD card, and if it does not exist, we have to show a dialog message.<br />
<br />
Therefore, add the following code to the ViewStudentApp.java class constructor:<br />
<source lang="java"><br />
<br />
public ViewStudentApp() throws Exception {<br />
//This part is from BB Sample application<br />
// Determine if an SDCard is present<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
<br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
// the rest of code goes here<br />
<br />
}<br />
</source><br />
<br />
===11.5 Copy Database File into SDCard===<br />
<br />
===11.6 Create SQLiteManager Class===<br />
11.6.1 Open Database<br/><br />
11.6.2 Close Database<br/><br />
11.6.3 Select All Students<br/><br />
11.6.4 Insert New Student<br/><br />
11.6.5 Delete Student<br/><br />
11.6.6 Update Student<br/><br />
<br />
===11.7 Modify StudentsList Class to use SQLiteManager===<br />
11.7.1 Load list<br/><br />
11.7.2 Add Student<br/><br />
11.7.3 Edit Student<br/><br />
11.7.4 Delete Student<br/><br />
<br />
===11.8 Student View Application in Action===</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62358Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-12T02:44:28Z<p>Ladanzahir: /* 11.2 Create Database File */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Add SDCard to Simulator===<br />
To be able to have data preserved on database, first we need to make sure that simulator can simulate SDCard, so that we can run our application with database. For this purpose first create a folder on your file system. Then run the simulator and from the top menu choose: Simulate > Change SD Card... .<br/><br />
Then Mount Directory, and select the folder you just created. Every time you restart the simulator, before running the app you need to make sure that the folder is mounted as SD Card. later on you will see that the database file gets created there.<br/><br />
[[Image: BB_SDCard.png | 350px]]<br/><br />
<br />
===11.2 Create Database File===<br />
We would like to create a database file including out Student Entity, so that we can put it in the project. Then every time the app runs, first it checks if it is the first time run of the app on the device or simulator. If so, the app will copy the file in to the SDCard. Next time that you run the application, it will know that the file is there, so will not override it. <Br/><br />
<br />
For this purpose, create a simple blackberry project with only the application object. We do not need any screen here. call it "DBCreator".<br />
and this will need to only have a class called MyApp.java which extends UIApplication. Here is the code for this class:<br />
<br />
<source lang="java" ><br />
<br />
package mypackage;<br />
<br />
import java.util.Enumeration;<br />
import javax.microedition.io.file.FileSystemRegistry;<br />
import net.rim.device.api.ui.*;<br />
import net.rim.device.api.ui.component.*;<br />
import net.rim.device.api.database.*;<br />
import net.rim.device.api.io.*;<br />
<br />
/**<br />
* This class extends the UiApplication class, providing a<br />
* graphical user interface.<br />
*/<br />
public class MyApp extends UiApplication<br />
{<br />
private static String DB_NAME = "SQLiteStudentList";<br />
<br />
/**<br />
* Entry point for application<br />
* @param args Command line arguments (not used)<br />
*/<br />
public static void main(String[] args) throws Exception<br />
{<br />
// Create a new instance of the application and make the currently<br />
// running thread the application's event dispatch thread.<br />
MyApp theApp = new MyApp(); <br />
theApp.enterEventDispatcher();<br />
}<br />
<br />
<br />
/**<br />
* Creates a new MyApp object<br />
*/<br />
public MyApp()throws Exception<br />
{ <br />
// Check for the presence of the SDCard<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
try{<br />
// create a URI object with te file name and location <br />
String dbLocation = "/SDCard/databases/DBCreator/";<br />
URI uri = URI.create(dbLocation + DB_NAME);<br />
<br />
// open a database connection to that URI<br />
Database db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false));<br />
<br />
// create the table if it does not already exist<br />
Statement statement =<br />
db.createStatement("CREATE TABLE IF NOT EXISTS Student(id INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT, email TEXT, address TEXT)");<br />
statement.prepare();<br />
<br />
//execute the statement<br />
statement.execute();<br />
<br />
// close statement and database<br />
statement.close(); <br />
db.close(); <br />
<br />
}catch(Exception ex ) {<br />
errorDialog(ex.getMessage());<br />
System.exit(0); <br />
}<br />
<br />
}<br />
}<br />
<br />
// Error message dialog<br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
}<br />
<br />
</source><br />
<br />
Now run tha application. Then from the SDCard folder, drag the database file and drop it into your main project, "res" folder.<br />
<br />
===11.3 Add id to Student Class===<br />
Now in our main application project,we need to add id to this class because we are going to preserve our Student objects in database,:<br />
So add a private field and add public getter and setters:<br />
<source lang="java"><br />
<br />
public int getId(){<br />
return this.id;<br />
}<br />
public void setId(int id){<br />
this.id = id;<br />
}<br />
</source><br />
<br />
===11.4 Check for presence of SDCard===<br />
<br />
===11.5 Copy Database File into SDCard===<br />
<br />
===11.6 Create SQLiteManager Class===<br />
11.6.1 Open Database<br/><br />
11.6.2 Close Database<br/><br />
11.6.3 Select All Students<br/><br />
11.6.4 Insert New Student<br/><br />
11.6.5 Delete Student<br/><br />
11.6.6 Update Student<br/><br />
<br />
===11.7 Modify StudentsList Class to use SQLiteManager===<br />
11.7.1 Load list<br/><br />
11.7.2 Add Student<br/><br />
11.7.3 Edit Student<br/><br />
11.7.4 Delete Student<br/><br />
<br />
===11.8 Student View Application in Action===</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62357Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-12T02:42:20Z<p>Ladanzahir: /* 11.3 Add id to Student Class */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Add SDCard to Simulator===<br />
To be able to have data preserved on database, first we need to make sure that simulator can simulate SDCard, so that we can run our application with database. For this purpose first create a folder on your file system. Then run the simulator and from the top menu choose: Simulate > Change SD Card... .<br/><br />
Then Mount Directory, and select the folder you just created. Every time you restart the simulator, before running the app you need to make sure that the folder is mounted as SD Card. later on you will see that the database file gets created there.<br/><br />
[[Image: BB_SDCard.png | 350px]]<br/><br />
<br />
===11.2 Create Database File===<br />
We would like to create a database file including out Student Entity, so that we can put it in the project. Then every time the app runs, first it checks if it is the first time run of the app on the device or simulator. If so, the app will copy the file in to the SDCard. Next time that you run the application, it will know that the file is there, so will not override it. <Br/><br />
<br />
For this purpose, create a simple blackberry project with only the application object. We do not need any screen here. call it "DBCreator".<br />
and this will need to only have a class called MyApp.java which extends UIApplication. Here is the code for this class:<br />
<br />
<source lang="java" ><br />
<br />
package mypackage;<br />
<br />
import java.util.Enumeration;<br />
import javax.microedition.io.file.FileSystemRegistry;<br />
import net.rim.device.api.ui.*;<br />
import net.rim.device.api.ui.component.*;<br />
import net.rim.device.api.database.*;<br />
import net.rim.device.api.io.*;<br />
<br />
/**<br />
* This class extends the UiApplication class, providing a<br />
* graphical user interface.<br />
*/<br />
public class MyApp extends UiApplication<br />
{<br />
private static String DB_NAME = "SQLiteStudentList";<br />
<br />
/**<br />
* Entry point for application<br />
* @param args Command line arguments (not used)<br />
*/<br />
public static void main(String[] args) throws Exception<br />
{<br />
// Create a new instance of the application and make the currently<br />
// running thread the application's event dispatch thread.<br />
MyApp theApp = new MyApp(); <br />
theApp.enterEventDispatcher();<br />
}<br />
<br />
<br />
/**<br />
* Creates a new MyApp object<br />
*/<br />
public MyApp()throws Exception<br />
{ <br />
// Check for the presence of the SDCard<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
try{<br />
// create a URI object with te file name and location <br />
String dbLocation = "/SDCard/databases/DBCreator/";<br />
URI uri = URI.create(dbLocation + DB_NAME);<br />
<br />
// open a database connection to that URI<br />
Database db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false));<br />
<br />
// create the table if it does not already exist<br />
Statement statement =<br />
db.createStatement("CREATE TABLE IF NOT EXISTS Student(id INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT, email TEXT, address TEXT)");<br />
statement.prepare();<br />
<br />
//execute the statement<br />
statement.execute();<br />
<br />
// close statement and database<br />
statement.close(); <br />
db.close(); <br />
<br />
}catch(Exception ex ) {<br />
errorDialog(ex.getMessage());<br />
System.exit(0); <br />
}<br />
<br />
}<br />
}<br />
<br />
// Error message dialog<br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
}<br />
<br />
<br />
<br />
</source><br />
<br />
===11.3 Add id to Student Class===<br />
Now in our main application project,we need to add id to this class because we are going to preserve our Student objects in database,:<br />
So add a private field and add public getter and setters:<br />
<source lang="java"><br />
<br />
public int getId(){<br />
return this.id;<br />
}<br />
public void setId(int id){<br />
this.id = id;<br />
}<br />
</source><br />
<br />
===11.4 Check for presence of SDCard===<br />
<br />
===11.5 Copy Database File into SDCard===<br />
<br />
===11.6 Create SQLiteManager Class===<br />
11.6.1 Open Database<br/><br />
11.6.2 Close Database<br/><br />
11.6.3 Select All Students<br/><br />
11.6.4 Insert New Student<br/><br />
11.6.5 Delete Student<br/><br />
11.6.6 Update Student<br/><br />
<br />
===11.7 Modify StudentsList Class to use SQLiteManager===<br />
11.7.1 Load list<br/><br />
11.7.2 Add Student<br/><br />
11.7.3 Edit Student<br/><br />
11.7.4 Delete Student<br/><br />
<br />
===11.8 Student View Application in Action===</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62356Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-12T02:34:21Z<p>Ladanzahir: /* 11.2 Create Database File */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Add SDCard to Simulator===<br />
To be able to have data preserved on database, first we need to make sure that simulator can simulate SDCard, so that we can run our application with database. For this purpose first create a folder on your file system. Then run the simulator and from the top menu choose: Simulate > Change SD Card... .<br/><br />
Then Mount Directory, and select the folder you just created. Every time you restart the simulator, before running the app you need to make sure that the folder is mounted as SD Card. later on you will see that the database file gets created there.<br/><br />
[[Image: BB_SDCard.png | 350px]]<br/><br />
<br />
===11.2 Create Database File===<br />
We would like to create a database file including out Student Entity, so that we can put it in the project. Then every time the app runs, first it checks if it is the first time run of the app on the device or simulator. If so, the app will copy the file in to the SDCard. Next time that you run the application, it will know that the file is there, so will not override it. <Br/><br />
<br />
For this purpose, create a simple blackberry project with only the application object. We do not need any screen here. call it "DBCreator".<br />
and this will need to only have a class called MyApp.java which extends UIApplication. Here is the code for this class:<br />
<br />
<source lang="java" ><br />
<br />
package mypackage;<br />
<br />
import java.util.Enumeration;<br />
import javax.microedition.io.file.FileSystemRegistry;<br />
import net.rim.device.api.ui.*;<br />
import net.rim.device.api.ui.component.*;<br />
import net.rim.device.api.database.*;<br />
import net.rim.device.api.io.*;<br />
<br />
/**<br />
* This class extends the UiApplication class, providing a<br />
* graphical user interface.<br />
*/<br />
public class MyApp extends UiApplication<br />
{<br />
private static String DB_NAME = "SQLiteStudentList";<br />
<br />
/**<br />
* Entry point for application<br />
* @param args Command line arguments (not used)<br />
*/<br />
public static void main(String[] args) throws Exception<br />
{<br />
// Create a new instance of the application and make the currently<br />
// running thread the application's event dispatch thread.<br />
MyApp theApp = new MyApp(); <br />
theApp.enterEventDispatcher();<br />
}<br />
<br />
<br />
/**<br />
* Creates a new MyApp object<br />
*/<br />
public MyApp()throws Exception<br />
{ <br />
// Check for the presence of the SDCard<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
try{<br />
// create a URI object with te file name and location <br />
String dbLocation = "/SDCard/databases/DBCreator/";<br />
URI uri = URI.create(dbLocation + DB_NAME);<br />
<br />
// open a database connection to that URI<br />
Database db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false));<br />
<br />
// create the table if it does not already exist<br />
Statement statement =<br />
db.createStatement("CREATE TABLE IF NOT EXISTS Student(id INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT, email TEXT, address TEXT)");<br />
statement.prepare();<br />
<br />
//execute the statement<br />
statement.execute();<br />
<br />
// close statement and database<br />
statement.close(); <br />
db.close(); <br />
<br />
}catch(Exception ex ) {<br />
errorDialog(ex.getMessage());<br />
System.exit(0); <br />
}<br />
<br />
}<br />
}<br />
<br />
// Error message dialog<br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
}<br />
<br />
<br />
<br />
</source><br />
<br />
===11.3 Add id to Student Class===<br />
<br />
===11.4 Check for presence of SDCard===<br />
<br />
===11.5 Copy Database File into SDCard===<br />
<br />
===11.6 Create SQLiteManager Class===<br />
11.6.1 Open Database<br/><br />
11.6.2 Close Database<br/><br />
11.6.3 Select All Students<br/><br />
11.6.4 Insert New Student<br/><br />
11.6.5 Delete Student<br/><br />
11.6.6 Update Student<br/><br />
<br />
===11.7 Modify StudentsList Class to use SQLiteManager===<br />
11.7.1 Load list<br/><br />
11.7.2 Add Student<br/><br />
11.7.3 Edit Student<br/><br />
11.7.4 Delete Student<br/><br />
<br />
===11.8 Student View Application in Action===</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62355Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-12T02:32:59Z<p>Ladanzahir: /* 11.2 Create Database File */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Add SDCard to Simulator===<br />
To be able to have data preserved on database, first we need to make sure that simulator can simulate SDCard, so that we can run our application with database. For this purpose first create a folder on your file system. Then run the simulator and from the top menu choose: Simulate > Change SD Card... .<br/><br />
Then Mount Directory, and select the folder you just created. Every time you restart the simulator, before running the app you need to make sure that the folder is mounted as SD Card. later on you will see that the database file gets created there.<br/><br />
[[Image: BB_SDCard.png | 350px]]<br/><br />
<br />
===11.2 Create Database File===<br />
We would like to create a database file including out Student Entity, so that we can put it in the project. Then every time the app runs, first it checks if it is the first time run of the app on the device or simulator. If so, the app will copy the file in to the SDCard. Next time that you run the application, it will know that the file is there, so will not override it. <Br/><br />
<br />
For this purpose, create a simple blackberry project with only the application object. We do not need any screen here. call it "DBCreator".<br />
and this will need to only have a class called MyApp.java which extends UIApplication. Here is the code for this class:<br />
<br />
<source lang="java" ><br />
<br />
package mypackage;<br />
<br />
import java.util.Enumeration;<br />
import javax.microedition.io.file.FileSystemRegistry;<br />
import net.rim.device.api.ui.*;<br />
import net.rim.device.api.ui.component.*;<br />
import net.rim.device.api.database.*;<br />
import net.rim.device.api.io.*;<br />
<br />
/**<br />
* This class extends the UiApplication class, providing a<br />
* graphical user interface.<br />
*/<br />
public class MyApp extends UiApplication<br />
{<br />
private static String DB_NAME = "SQLiteStudentList";<br />
<br />
/**<br />
* Entry point for application<br />
* @param args Command line arguments (not used)<br />
*/<br />
public static void main(String[] args) throws Exception<br />
{<br />
// Create a new instance of the application and make the currently<br />
// running thread the application's event dispatch thread.<br />
MyApp theApp = new MyApp(); <br />
theApp.enterEventDispatcher();<br />
}<br />
<br />
<br />
/**<br />
* Creates a new MyApp object<br />
*/<br />
public MyApp()throws Exception<br />
{ <br />
// Push a screen onto the UI stack for rendering.<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
try{<br />
// create a URI object with te file name and location <br />
String dbLocation = "/SDCard/databases/DBCreator/";<br />
URI uri = URI.create(dbLocation + DB_NAME);<br />
<br />
// open a database connection to that URI<br />
Database db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false));<br />
<br />
// create the table if it does not already exist<br />
Statement statement =<br />
db.createStatement("CREATE TABLE IF NOT EXISTS Student(id INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT, email TEXT, address TEXT)");<br />
statement.prepare();<br />
<br />
//execute the statement<br />
statement.execute();<br />
<br />
// close statement and database<br />
statement.close(); <br />
db.close(); <br />
<br />
}catch(Exception ex ) {<br />
errorDialog(ex.getMessage());<br />
System.exit(0); <br />
}<br />
<br />
}<br />
}<br />
<br />
// Error message dialog<br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
}<br />
<br />
<br />
<br />
</source><br />
<br />
===11.3 Add id to Student Class===<br />
<br />
===11.4 Check for presence of SDCard===<br />
<br />
===11.5 Copy Database File into SDCard===<br />
<br />
===11.6 Create SQLiteManager Class===<br />
11.6.1 Open Database<br/><br />
11.6.2 Close Database<br/><br />
11.6.3 Select All Students<br/><br />
11.6.4 Insert New Student<br/><br />
11.6.5 Delete Student<br/><br />
11.6.6 Update Student<br/><br />
<br />
===11.7 Modify StudentsList Class to use SQLiteManager===<br />
11.7.1 Load list<br/><br />
11.7.2 Add Student<br/><br />
11.7.3 Edit Student<br/><br />
11.7.4 Delete Student<br/><br />
<br />
===11.8 Student View Application in Action===</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62354Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-12T02:32:11Z<p>Ladanzahir: /* 11.2 Create Database File */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Add SDCard to Simulator===<br />
To be able to have data preserved on database, first we need to make sure that simulator can simulate SDCard, so that we can run our application with database. For this purpose first create a folder on your file system. Then run the simulator and from the top menu choose: Simulate > Change SD Card... .<br/><br />
Then Mount Directory, and select the folder you just created. Every time you restart the simulator, before running the app you need to make sure that the folder is mounted as SD Card. later on you will see that the database file gets created there.<br/><br />
[[Image: BB_SDCard.png | 350px]]<br/><br />
<br />
===11.2 Create Database File===<br />
We would like to create a database file including out Student Entity, so that we can put it in the project. Then every time the app runs, first it checks if it is the first time run of the app on the device or simulator. If so, the app will copy the file in to the SDCard. Next time that you run the application, it will know that the file is there, so will not override it. <Br/><br />
<br />
For this purpose, create a simple blackberry project with only the application object. We do not need any screen here. call it "DBCreator".<br />
and this will need to only have a class called MyApp.java which extends UIApplication. Here is the code for this class:<br />
<br />
<source lang="java" ><br />
<br />
package mypackage;<br />
<br />
import java.util.Enumeration;<br />
import javax.microedition.io.file.FileSystemRegistry;<br />
import net.rim.device.api.ui.*;<br />
import net.rim.device.api.ui.component.*;<br />
import net.rim.device.api.database.*;<br />
import net.rim.device.api.io.*;<br />
<br />
/**<br />
* This class extends the UiApplication class, providing a<br />
* graphical user interface.<br />
*/<br />
public class MyApp extends UiApplication<br />
{<br />
private static String DB_NAME = "SQLiteStudentList";<br />
<br />
/**<br />
* Entry point for application<br />
* @param args Command line arguments (not used)<br />
*/<br />
public static void main(String[] args) throws Exception<br />
{<br />
// Create a new instance of the application and make the currently<br />
// running thread the application's event dispatch thread.<br />
MyApp theApp = new MyApp(); <br />
theApp.enterEventDispatcher();<br />
}<br />
<br />
<br />
/**<br />
* Creates a new MyApp object<br />
*/<br />
public MyApp()throws Exception<br />
{ <br />
// Push a screen onto the UI stack for rendering.<br />
boolean sdCardPresent = false;<br />
String root = null;<br />
Enumeration e = FileSystemRegistry.listRoots();<br />
while (e.hasMoreElements())<br />
{<br />
root = (String)e.nextElement();<br />
if(root.equalsIgnoreCase("sdcard/"))<br />
{<br />
sdCardPresent = true;<br />
} <br />
} <br />
if(!sdCardPresent)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert("This application requires an SD card to be present. Exiting application...");<br />
System.exit(0); <br />
}<br />
}); <br />
} <br />
else<br />
{<br />
try{<br />
// create a URI object with te file name and location <br />
String dbLocation = "/SDCard/databases/DBCreator/";<br />
URI uri = URI.create(dbLocation + DB_NAME);<br />
<br />
// open a database connection to that URI<br />
Database db = DatabaseFactory.openOrCreate(uri, new DatabaseSecurityOptions(false));<br />
<br />
// create the table if it does not already exist<br />
Statement statement = db.createStatement("CREATE TABLE IF NOT EXISTS Student(id INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT, email TEXT, address TEXT)");<br />
statement.prepare();<br />
<br />
//execute the statement<br />
statement.execute();<br />
<br />
// close statement and database<br />
statement.close(); <br />
db.close(); <br />
<br />
}catch(Exception ex ) {<br />
errorDialog(ex.getMessage());<br />
System.exit(0); <br />
}<br />
<br />
}<br />
}<br />
<br />
// Error message dialog<br />
public static void errorDialog(final String message)<br />
{<br />
UiApplication.getUiApplication().invokeLater(new Runnable()<br />
{<br />
public void run()<br />
{<br />
Dialog.alert(message);<br />
}<br />
});<br />
}<br />
}<br />
<br />
<br />
<br />
</source><br />
<br />
===11.3 Add id to Student Class===<br />
<br />
===11.4 Check for presence of SDCard===<br />
<br />
===11.5 Copy Database File into SDCard===<br />
<br />
===11.6 Create SQLiteManager Class===<br />
11.6.1 Open Database<br/><br />
11.6.2 Close Database<br/><br />
11.6.3 Select All Students<br/><br />
11.6.4 Insert New Student<br/><br />
11.6.5 Delete Student<br/><br />
11.6.6 Update Student<br/><br />
<br />
===11.7 Modify StudentsList Class to use SQLiteManager===<br />
11.7.1 Load list<br/><br />
11.7.2 Add Student<br/><br />
11.7.3 Edit Student<br/><br />
11.7.4 Delete Student<br/><br />
<br />
===11.8 Student View Application in Action===</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62353Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-12T02:21:39Z<p>Ladanzahir: /* 11.1 Add SDCard to Simulator */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Add SDCard to Simulator===<br />
To be able to have data preserved on database, first we need to make sure that simulator can simulate SDCard, so that we can run our application with database. For this purpose first create a folder on your file system. Then run the simulator and from the top menu choose: Simulate > Change SD Card... .<br/><br />
Then Mount Directory, and select the folder you just created. Every time you restart the simulator, before running the app you need to make sure that the folder is mounted as SD Card. later on you will see that the database file gets created there.<br/><br />
[[Image: BB_SDCard.png | 350px]]<br/><br />
<br />
===11.2 Create Database File===<br />
<br />
===11.3 Add id to Student Class===<br />
<br />
===11.4 Check for presence of SDCard===<br />
<br />
===11.5 Copy Database File into SDCard===<br />
<br />
===11.6 Create SQLiteManager Class===<br />
11.6.1 Open Database<br/><br />
11.6.2 Close Database<br/><br />
11.6.3 Select All Students<br/><br />
11.6.4 Insert New Student<br/><br />
11.6.5 Delete Student<br/><br />
11.6.6 Update Student<br/><br />
<br />
===11.7 Modify StudentsList Class to use SQLiteManager===<br />
11.7.1 Load list<br/><br />
11.7.2 Add Student<br/><br />
11.7.3 Edit Student<br/><br />
11.7.4 Delete Student<br/><br />
<br />
===11.8 Student View Application in Action===</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=File:BB_SDCard.png&diff=62352File:BB SDCard.png2011-04-12T02:21:05Z<p>Ladanzahir: </p>
<hr />
<div></div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62351Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-12T02:20:47Z<p>Ladanzahir: /* 11.1 Add SDCard to Simulator */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Add SDCard to Simulator===<br />
To be able to have data preserved on database, first we need to make sure that simulator can simulate SDCard, so that we can run our application with database. For this purpose first create a folder on your file system. Then run the simulator and from the top menu choose: Simulate > Change SD Card... .<br/><br />
Then Mount Directory, and select the folder you just created. Every time you restart the simulator, before running the app you need to make sure that the folder is mounted as SD Card. later on you will see that the database file gets created there.<br/><br />
[[Image: BB_SDCard.png | 300px]]<br/><br />
<br />
===11.2 Create Database File===<br />
<br />
===11.3 Add id to Student Class===<br />
<br />
===11.4 Check for presence of SDCard===<br />
<br />
===11.5 Copy Database File into SDCard===<br />
<br />
===11.6 Create SQLiteManager Class===<br />
11.6.1 Open Database<br/><br />
11.6.2 Close Database<br/><br />
11.6.3 Select All Students<br/><br />
11.6.4 Insert New Student<br/><br />
11.6.5 Delete Student<br/><br />
11.6.6 Update Student<br/><br />
<br />
===11.7 Modify StudentsList Class to use SQLiteManager===<br />
11.7.1 Load list<br/><br />
11.7.2 Add Student<br/><br />
11.7.3 Edit Student<br/><br />
11.7.4 Delete Student<br/><br />
<br />
===11.8 Student View Application in Action===</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62350Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-12T02:18:29Z<p>Ladanzahir: /* 11.1 Add SDCard to Simulator */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Add SDCard to Simulator===<br />
To be able to have data preserved on database, first we need to make sure that simulator can simulate SDCard, so that we can run our application with database. For this purpose first create a folder on your file system. Then run the simulator and from the top menu choose: Simulate > Change SD Card... , then Mount Directory, and select the folder you just created. Every time you restart the simulator, before running the app you need to make sure that the folder is mounted as SD Card. later on you will see that the database file gets created there.<br />
<br />
===11.2 Create Database File===<br />
<br />
===11.3 Add id to Student Class===<br />
<br />
===11.4 Check for presence of SDCard===<br />
<br />
===11.5 Copy Database File into SDCard===<br />
<br />
===11.6 Create SQLiteManager Class===<br />
11.6.1 Open Database<br/><br />
11.6.2 Close Database<br/><br />
11.6.3 Select All Students<br/><br />
11.6.4 Insert New Student<br/><br />
11.6.5 Delete Student<br/><br />
11.6.6 Update Student<br/><br />
<br />
===11.7 Modify StudentsList Class to use SQLiteManager===<br />
11.7.1 Load list<br/><br />
11.7.2 Add Student<br/><br />
11.7.3 Edit Student<br/><br />
11.7.4 Delete Student<br/><br />
<br />
===11.8 Student View Application in Action===</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62349Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-12T01:35:31Z<p>Ladanzahir: /* 11. Use Database and SQLite to Store Data */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Add SDCard to Simulator===<br />
===11.2 Create Database File===<br />
<br />
===11.3 Add id to Student Class===<br />
<br />
===11.4 Check for presence of SDCard===<br />
<br />
===11.5 Copy Database File into SDCard===<br />
<br />
===11.6 Create SQLiteManager Class===<br />
11.6.1 Open Database<br/><br />
11.6.2 Close Database<br/><br />
11.6.3 Select All Students<br/><br />
11.6.4 Insert New Student<br/><br />
11.6.5 Delete Student<br/><br />
11.6.6 Update Student<br/><br />
<br />
===11.7 Modify StudentsList Class to use SQLiteManager===<br />
11.7.1 Load list<br/><br />
11.7.2 Add Student<br/><br />
11.7.3 Edit Student<br/><br />
11.7.4 Delete Student<br/><br />
<br />
===11.8 Student View Application in Action===</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62023Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-08T20:23:10Z<p>Ladanzahir: </p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Create Database File===<br />
<br />
===11.2 Add id to Student Class===<br />
<br />
===11.3 Check for presence of SDCard===<br />
<br />
===11.4 Copy Database File into SDCard===<br />
<br />
===11.3 Create SQLiteManager Class===<br />
11.3.1 Open Database<br/><br />
11.3.2 Close Database<br/><br />
11.3.3 Select All Students<br/><br />
11.3.4 Insert New Student<br/><br />
11.3.5 Delete Student<br/><br />
11.3.6 Update Student<br/><br />
<br />
===11.4 Modify StudentsList Class to use SQLiteManager===<br />
11.4.1 Load list<br/><br />
11.4.2 Add Student<br/><br />
11.4.3 Edit Student<br/><br />
11.4.4 Delete Student<br/><br />
<br />
===11.5 Add SDCard to Simulator===<br />
<br />
===11.6 Student View Application in Action===</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62022Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-08T20:19:58Z<p>Ladanzahir: /* Use Database and SQLite to Store Data */</p>
<hr />
<div>==11. Use Database and SQLite to Store Data==<br />
<br />
===11.1 Create Database File===<br />
<br />
===11.2 Add id to Student Class===<br />
<br />
===11.3 Check for presence of SDCard===<br />
<br />
===11.4 Copy Database File into SDCard===<br />
<br />
===11.3 Create SQLiteManager Class===<br />
11.3.1 Open Database<br/><br />
11.3.2 Close Database<br/><br />
11.3.3 Select All Students<br/><br />
11.3.4 Insert New Student<br/><br />
11.3.5 Delete Student<br/><br />
11.3.6 Update Student<br/><br />
<br />
===11.4 Modify StudentsList Class to use SQLiteManager===<br />
11.4.1 Load list<br/><br />
11.4.2 Add Student<br/><br />
11.4.3 Edit Student<br/><br />
11.4.4 Delete Student<br/></div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/BlackBerry/Use_SQLite&diff=62020Teams Winter 2011/team1/BlackBerry/Use SQLite2011-04-08T20:09:06Z<p>Ladanzahir: Created page with '==Use Database and SQLite to Store Data=='</p>
<hr />
<div>==Use Database and SQLite to Store Data==</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1&diff=62019Teams Winter 2011/team12011-04-08T20:08:30Z<p>Ladanzahir: </p>
<hr />
<div>===Team 1 - Eclipse Tutorials===<br />
<br />
* '''Lab 1- Basics Tutorial'''<br />
<br />
# [[team1/Preparing Eclipse | Preparing Eclipse]]<br />
# [[team1/Creating your first Java project | Creating your first Java project]]<br />
# [[team1/Browsing Java elements using the package explorer | Browsing Java elements using the package explorer]]<br />
# [[team1/Editing Java elements | Editing Java elements]]<br />
# [[team1/Creating a Java class | Creating a Java class]]<br />
# [[team1/Renaming Java elements | Renaming Java elements]]<br />
# [[team1/Moving and copying Java elements | Moving and copying Java elements]]<br />
# [[team1/Navigate to a Java element's declaration | Navigate to a Java element's declaration]]<br />
# [[team1/Viewing the type Hierarchy | Viewing the type Hierarchy]]<br />
# [[team1/Searching the workbench | Searching the workbench]]<br />
# [[team1/Running your programs | Running your programs]]<br />
# [[team1/Debugging your programs | Debugging your programs]]<br />
# [[team1/Evaluating expressions | Evaluating expressions]]<br />
# [[team1/Evaluating snippets | Evaluating snippets]]<br />
# [[team1/Using the Java browsing perspective | Using the Java browsing perspective]]<br />
# [[team1/Writing and running JUnit tests | Writing and running JUnit tests]]<br />
<br />
* '''Lab 2 - OSGI Tutorial'''<br />
# [[Teams_Winter_2011/team1/OSGI/Create_the_Service_Interface | Create the Service Interface ]]<br />
# [[Teams_Winter_2011/team1/OSGI/Implement_the_Service_Provider | Implement the Service Provider]]<br />
# [[Teams_Winter_2011/team1/OSGI/Implement_the_Service_Consumer | Implement the Service Consumer]]<br />
<br />
* '''Lab 3 - RCP Tutorial'''<br />
# [[Teams_Winter_2011/team1/RCP/Create_RPC_Application | Create RPC Application ]]<br />
# [[Teams_Winter_2011/team1/RCP/Define_and_use_commands | Define and Use Commands ]]<br />
# [[Teams_Winter_2011/team1/RCP/Define_and_use_editors | Define and Use Editors ]]<br />
# [[Teams_Winter_2011/team1/RCP/Define_and_use_JFace | Define and Use JFace Viewers ]]<br />
# [[Teams_Winter_2011/team1/RCP/Create_configuration | Create Configuration for RCP Application ]]<br />
<br />
<div id="lab4"><br />
* '''Lab 4 - BlackBerry Tutorial'''<br />
# [[Teams_Winter_2011/team1/BlackBerry/Create_BlackBerry_Project | Create BlackBerry Project ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Change_Project_Icon | Change Project Icon and Output Name ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Add_Elements_to_Main_Screen | Add Elements on Main Screen ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Add_Menu_to_the_Application | Add Menu to the Application ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Add_Elements_to_View_Screen | Add Elements to View Screen ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Add_Elements_to_Add_Screen | Add Elements to Add Screen ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Implement_Delete_Option | Implement Delete Student Option ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Implement_Edit_Option | Implement Edit Student Option]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Add_Send_Email_Option | Add Send E-mail Option ]]<br />
</div><br />
<div id="lab5"><br />
* '''Lab 5 - Android Tutorial'''<br />
# [[Teams_Winter_2011/team1/Android/Create_Android_Project | Create Android Project ]]<br />
# [[Teams_Winter_2011/team1/Android/Adding_Elements_to_Main_Screen | Adding Elements to Main Screen ]]<br />
# [[Teams_Winter_2011/team1/Android/Adding_Functionality_to_Main_Screen_Elements | Adding Functionality to Main Screen Elements ]]<br />
# [[Teams_Winter_2011/team1/Android/Add_Options_Menu | Add Options Menu ]]<br />
# [[Teams_Winter_2011/team1/Android/Implement_Delete_Option | Implement Delete Option ]]<br />
# [[Teams_Winter_2011/team1/Android/Implement_View_Option | Implement View Option ]]<br />
# [[Teams_Winter_2011/team1/Android/Add_Contact | Add Contact ]]<br />
# [[Teams_Winter_2011/team1/Android/Edit_Contact | Edit Contact ]]<br />
# [[Teams_Winter_2011/team1/Android/Send_Email | Send Email ]]<br />
<br />
</div><br />
<div id="project"><br />
* '''Project - BlackBerry Application Development Tutorial'''<br />
# [[Teams_Winter_2011/team1/BlackBerry/Create_BlackBerry_Project | Create BlackBerry Project ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Change_Project_Icon | Change Project Icon and Output Name ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Add_Elements_to_Main_Screen | Add Elements on Main Screen ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Add_Menu_to_the_Application | Add Menu to the Application ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Add_Elements_to_View_Screen | Add Elements to View Screen ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Add_Elements_to_Add_Screen | Add Elements to Add Screen ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Implement_Delete_Option | Implement Delete Student Option ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Implement_Edit_Option | Implement Edit Student Option]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Add_Send_Email_Option | Add Send E-mail Option ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Add_Mapping_Option | Add Mapping Option ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Use_SQLite | Use Database and SQLite to Store Data ]]<br />
</div></div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1&diff=62018Teams Winter 2011/team12011-04-08T20:06:25Z<p>Ladanzahir: </p>
<hr />
<div>===Team 1 - Eclipse Tutorials===<br />
<br />
* '''Lab 1- Basics Tutorial'''<br />
<br />
# [[team1/Preparing Eclipse | Preparing Eclipse]]<br />
# [[team1/Creating your first Java project | Creating your first Java project]]<br />
# [[team1/Browsing Java elements using the package explorer | Browsing Java elements using the package explorer]]<br />
# [[team1/Editing Java elements | Editing Java elements]]<br />
# [[team1/Creating a Java class | Creating a Java class]]<br />
# [[team1/Renaming Java elements | Renaming Java elements]]<br />
# [[team1/Moving and copying Java elements | Moving and copying Java elements]]<br />
# [[team1/Navigate to a Java element's declaration | Navigate to a Java element's declaration]]<br />
# [[team1/Viewing the type Hierarchy | Viewing the type Hierarchy]]<br />
# [[team1/Searching the workbench | Searching the workbench]]<br />
# [[team1/Running your programs | Running your programs]]<br />
# [[team1/Debugging your programs | Debugging your programs]]<br />
# [[team1/Evaluating expressions | Evaluating expressions]]<br />
# [[team1/Evaluating snippets | Evaluating snippets]]<br />
# [[team1/Using the Java browsing perspective | Using the Java browsing perspective]]<br />
# [[team1/Writing and running JUnit tests | Writing and running JUnit tests]]<br />
<br />
* '''Lab 2 - OSGI Tutorial'''<br />
# [[Teams_Winter_2011/team1/OSGI/Create_the_Service_Interface | Create the Service Interface ]]<br />
# [[Teams_Winter_2011/team1/OSGI/Implement_the_Service_Provider | Implement the Service Provider]]<br />
# [[Teams_Winter_2011/team1/OSGI/Implement_the_Service_Consumer | Implement the Service Consumer]]<br />
<br />
* '''Lab 3 - RCP Tutorial'''<br />
# [[Teams_Winter_2011/team1/RCP/Create_RPC_Application | Create RPC Application ]]<br />
# [[Teams_Winter_2011/team1/RCP/Define_and_use_commands | Define and Use Commands ]]<br />
# [[Teams_Winter_2011/team1/RCP/Define_and_use_editors | Define and Use Editors ]]<br />
# [[Teams_Winter_2011/team1/RCP/Define_and_use_JFace | Define and Use JFace Viewers ]]<br />
# [[Teams_Winter_2011/team1/RCP/Create_configuration | Create Configuration for RCP Application ]]<br />
<br />
<div id="lab4"><br />
* '''Lab 4 - BlackBerry Tutorial'''<br />
# [[Teams_Winter_2011/team1/BlackBerry/Create_BlackBerry_Project | Create BlackBerry Project ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Change_Project_Icon | Change Project Icon and Output Name ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Add_Elements_to_Main_Screen | Add Elements on Main Screen ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Add_Menu_to_the_Application | Add Menu to the Application ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Add_Elements_to_View_Screen | Add Elements to View Screen ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Add_Elements_to_Add_Screen | Add Elements to Add Screen ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Implement_Delete_Option | Implement Delete Student Option ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Implement_Edit_Option | Implement Edit Student Option]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Add_Send_Email_Option | Add Send E-mail Option ]]<br />
</div><br />
<div id="lab5"><br />
* '''Lab 5 - Android Tutorial'''<br />
# [[Teams_Winter_2011/team1/Android/Create_Android_Project | Create Android Project ]]<br />
# [[Teams_Winter_2011/team1/Android/Adding_Elements_to_Main_Screen | Adding Elements to Main Screen ]]<br />
# [[Teams_Winter_2011/team1/Android/Adding_Functionality_to_Main_Screen_Elements | Adding Functionality to Main Screen Elements ]]<br />
# [[Teams_Winter_2011/team1/Android/Add_Options_Menu | Add Options Menu ]]<br />
# [[Teams_Winter_2011/team1/Android/Implement_Delete_Option | Implement Delete Option ]]<br />
# [[Teams_Winter_2011/team1/Android/Implement_View_Option | Implement View Option ]]<br />
# [[Teams_Winter_2011/team1/Android/Add_Contact | Add Contact ]]<br />
# [[Teams_Winter_2011/team1/Android/Edit_Contact | Edit Contact ]]<br />
# [[Teams_Winter_2011/team1/Android/Send_Email | Send Email ]]<br />
<br />
</div><br />
<div id="project"><br />
* '''Project - BlackBerry Application Development Tutorial'''<br />
# [[Teams_Winter_2011/team1/BlackBerry/Create_BlackBerry_Project | Create BlackBerry Project ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Change_Project_Icon | Change Project Icon and Output Name ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Add_Elements_to_Main_Screen | Add Elements on Main Screen ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Add_Menu_to_the_Application | Add Menu to the Application ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Add_Elements_to_View_Screen | Add Elements to View Screen ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Add_Elements_to_Add_Screen | Add Elements to Add Screen ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Implement_Delete_Option | Implement Delete Student Option ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Implement_Edit_Option | Implement Edit Student Option]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Add_Send_Email_Option | Add Send E-mail Option ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Add_Mapping_Option | Add Mapping Option ]]<br />
# [[Teams_Winter_2011/team1/BlackBerry/Use_SQLite | Use Database and SQLite to store data ]]<br />
</div></div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Android_:_Tutorials&diff=61941Android : Tutorials2011-04-08T02:10:32Z<p>Ladanzahir: </p>
<hr />
<div>{{Ecl_r|Android|Tutorials}}<br />
<br />
{{Ecl_r_entry |c=0<br />
|url= http://zenit.senecac.on.ca/~ecl500_111a07/labs/DPS914Lab5AndroidLabTeam7.pdf<br />
|title= Android Lab - Team 7 DPS914; Winter 2011 <br />
|descr= Due: April 6, 2011; Objective of the lab is to create Android application with Eclipse. <br />
<br />
}}<br />
<br />
{{Ecl_r_entry |c=0<br />
|url= http://zenit.senecac.on.ca/wiki/index.php/Teams_Winter_2011/team1#lab5<br />
|title= Android Lab - Team 1 ECL500; Winter 2011 <br />
|descr= Tutorial to create an Android application which lets user add, delete and edit a contact info and send email to the contact.<br />
<br />
}}</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Android_:_Tutorials&diff=61940Android : Tutorials2011-04-08T02:10:04Z<p>Ladanzahir: </p>
<hr />
<div>{{Ecl_r|Android|Tutorials}}<br />
<br />
{{Ecl_r_entry |c=0<br />
|url= http://zenit.senecac.on.ca/~ecl500_111a07/labs/DPS914Lab5AndroidLabTeam7.pdf<br />
|title= Android Lab - Team 7 DPS914; Winter 2011 <br />
|descr= Due: April 6, 2011; Objective of the lab is to create Android application with Eclipse. <br />
<br />
}}<br />
<br />
{{Ecl_r_entry |c=0<br />
|url= http://zenit.senecac.on.ca/wiki/index.php/Teams_Winter_2011/team1#lab5<br />
|title= Android Lab - Team 1 ECL500; Winter 2011 <br />
|descr= Tutorial to create an Android application which lets user to add delete and edit a contact data and send email to the contact.<br />
<br />
}}</div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/Android/Edit_Contact&diff=61901Teams Winter 2011/team1/Android/Edit Contact2011-04-07T17:36:28Z<p>Ladanzahir: /* 8.1 Create Edit Layout and Menu Item */</p>
<hr />
<div>== 8. Edit Contact ==<br />
===8.1 Create Edit Layout and Menu Item===<br />
8.1.1 Add the String value for the layout title to String.xml:<br />
<source lang="java"><br />
<string name="editContact_textView">Edit Contact</string><br />
</source><br />
8.1.2 Right click on layout -> New -> Android XML File .<br/><br />
8.1.3 Enter edit.xml for the file name and check Layout:<br/><br />
8.1.4 Using Linear Layout, create this layout for editing contact information:<br/><br />
[[Image: editContactLayout.png | 250px]]<br/><br />
8.1.5 Here is the edit.xml implementation:<br />
<source lang="java"><br />
<?xml version="1.0" encoding="utf-8"?><br />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"<br />
android:layout_width="match_parent" android:layout_height="match_parent"<br />
android:orientation="vertical"><br />
<TextView android:layout_width="wrap_content"<br />
android:layout_height="wrap_content" android:id="@+id/titleTextViewEdit"<br />
android:gravity="center_vertical" android:textSize="30dp"<br />
android:layout_gravity="center" android:text="@string/editContact_textView"></TextView><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:layout_marginBottom="3dp" android:hint="@string/hint_first_name" android:id="@+id/firstNameEdit"></EditText><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:isScrollContainer="true"<br />
android:layout_marginBottom="3dp" android:hint="@string/hint_last_name" android:id="@+id/lastNameEdit"></EditText><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:layout_marginBottom="3dp" android:hint="@string/hint_email" android:id="@+id/emailEdit"></EditText><br />
<br />
<Button android:layout_width="wrap_content"<br />
android:layout_height="wrap_content" android:id="@+id/saveContact_buttonEdit"<br />
android:text="@string/saveButton" android:gravity="center_horizontal"<br />
android:layout_gravity="center_horizontal" android:textSize="20dp"></Button><br />
</LinearLayout><br />
</source><br />
8.1.6 Now Add the Edit menu Item. for this purpose click on menu.xml and brouse to the xml view, and add the menu item. Here is how it looks like:<br />
<source lang="java"><br />
<?xml version="1.0" encoding="utf-8"?><br />
<menu<br />
xmlns:android="http://schemas.android.com/apk/res/android"><br />
<item android:id="@+id/item1" android:title="Add Student"></item><br />
<item android:id="@+id/item2" android:title="Delete Student"></item><br />
<item android:id="@+id/item3" android:title="View Student"></item><br />
<item android:id="@+id/item4" android:title="Edit Student"></item><br />
<item android:id="@+id/item5" android:title="Send E-mail"></item><br />
</menu><br />
</source><br />
<br />
<br />
8.1.. Now build your project so that the ids are generated in R.java<br />
<br />
===8.2 Create EditContactActivity===<br />
8.2.1 Create the EditContactActivity in your package and make sure it extends Activity class.<br />
<source lang="java"><br />
package cs.ecl.team1.android;<br />
<br />
import android.app.Activity;<br />
public class AddContactActivity extends Activity {<br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
}<br />
}<br />
</source><br />
<br />
8.2.2 Add private fields:<br />
<source lang="java"><br />
private String firstName;<br />
private String lastName;<br />
private String email;<br />
</source><br />
8.2.3 Make sure that on creation it adds the edit layout to the view, so change the OnCreate method:<br />
<source lang="java"><br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.edit); // adds edit layout to view<br />
}<br />
}<br />
</source><br />
8.2.4 get the Intent of this Activity (later when starting this activity, we will send an Intent including the data of the selected student for editing). Then read he data from it and set the EditTexts values:<br />
<source lang="java"><br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.edit); // adds edit layout to view<br />
<br />
Intent i = this.getIntent(); // get this page intent<br />
<br />
// read the data from the Intent<br />
EditText fNameEditText = (EditText) findViewById(R.id.firstNameEdit);<br />
fNameEditText.setText(i.getStringExtra("oldFirstName"));<br />
<br />
EditText lNameEditText = (EditText) findViewById(R.id.lastNameEdit);<br />
lNameEditText.setText(i.getStringExtra("oldLastName"));<br />
<br />
EditText emailEditText = (EditText) findViewById(R.id.emailEdit);<br />
emailEditText.setText(i.getStringExtra("oldEmail"));<br />
<br />
<br />
}<br />
}<br />
</source><br />
<br />
8.2.5 Add and implement the save button: in the OnCreate method:<br />
<br />
<source lang="java"><br />
//save Button implementation<br />
Button saveButton = (Button) findViewById(R.id.saveContact_buttonEdit);<br />
saveButton.setOnClickListener(new OnClickListener() {<br />
public void onClick(View arg0) {<br />
firstName = ((EditText) findViewById(R.id.firstNameEdit)).getText().toString();<br />
lastName = ((EditText) findViewById(R.id.lastNameEdit)).getText().toString();<br />
email = ((EditText) findViewById(R.id.emailEdit)).getText().toString();<br />
<br />
finish();<br />
}<br />
});<br />
</source><br />
<br />
8.3.5 Now you need to override the finish() method:<br />
<source lang="java"><br />
@Override<br />
public void finish() {<br />
Intent i = new Intent();<br />
if (firstName.equals("") && lastName.equals("") && email.equals("")) {<br />
setResult(0);<br />
}<br />
else { // add the modified data to the intent<br />
i.putExtra("newFirstName", firstName);<br />
i.putExtra("newLastName", lastName);<br />
i.putExtra("newEmail", email);<br />
setResult(RESULT_OK, i);<br />
}<br />
super.finish();<br />
}<br />
</source><br />
8.3.6 Here is the completed source of the EditContactActivity:<br />
<source lang="java"><br />
package cs.ecl.team1.android;<br />
<br />
import android.app.Activity;<br />
import android.content.Intent;<br />
import android.os.Bundle;<br />
import android.view.View;<br />
import android.view.View.OnClickListener;<br />
import android.widget.Button;<br />
import android.widget.EditText;<br />
<br />
<br />
public class EditContactActivity extends Activity {<br />
private String firstName;<br />
private String lastName;<br />
private String email;<br />
<br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
<br />
setContentView(R.layout.edit);<br />
<br />
// get the intent sent to this class<br />
Intent i = this.getIntent();<br />
<br />
EditText fNameEditText = (EditText) findViewById(R.id.firstNameEdit);<br />
fNameEditText.setText(i.getStringExtra("oldFirstName"));<br />
<br />
EditText lNameEditText = (EditText) findViewById(R.id.lastNameEdit);<br />
lNameEditText.setText(i.getStringExtra("oldLastName"));<br />
<br />
EditText emailEditText = (EditText) findViewById(R.id.emailEdit);<br />
emailEditText.setText(i.getStringExtra("oldEmail"));<br />
<br />
<br />
//save Button implementation<br />
Button saveButton = (Button) findViewById(R.id.saveContact_buttonEdit);<br />
saveButton.setOnClickListener(new OnClickListener() {<br />
public void onClick(View arg0) {<br />
firstName = ((EditText) findViewById(R.id.firstNameEdit)).getText().toString();<br />
lastName = ((EditText) findViewById(R.id.lastNameEdit)).getText().toString();<br />
email = ((EditText) findViewById(R.id.emailEdit)).getText().toString();<br />
<br />
finish();<br />
}<br />
});<br />
}<br />
<br />
@Override<br />
public void finish() {<br />
Intent i = new Intent();<br />
if (firstName.equals("") && lastName.equals("") && email.equals("")) {<br />
setResult(0);<br />
}<br />
else {<br />
i.putExtra("newFirstName", firstName);<br />
i.putExtra("newLastName", lastName);<br />
i.putExtra("newEmail", email);<br />
setResult(RESULT_OK, i);<br />
}<br />
super.finish();<br />
}<br />
<br />
<br />
}<br />
<br />
</source><br />
<br />
===8.3 Add the EditContactActivity to the Android Manifest===<br />
Now we have to declare our EditContactActivity in the Manifest:<br />
open the AndroidManifest.xml and add this:<br />
<source lang="java"><br />
<activity android:label="Edit Contact" android:name="EditContactActivity"></activity><br />
</source><br />
<br />
===8.4 Implement the EditContact in the main activity class===<br />
8.4.1 Add the following private fields to the ContactList Activity :<br />
<source lang=java><br />
// added for Edit<br />
private static final int EDIT_CONTACT =1;<br />
private Student selectedStudent;<br />
<br />
</source><br />
<br />
8.4.2 In the onOptionsItemSelected(MenuItem item) method add the following case to the switch code block:<br />
<br />
<source lang="java"><br />
case R.id.item4:// Edit<br />
// set the private field :selectedStudent so that it can be accessed later<br />
selectedStudent = (Student)contactsList.getSelectedItem();<br />
// create an Intent for EditContactActivity class<br />
Intent j = new Intent(this, EditContactActivity.class);<br />
// add the selected student's data to the intent so that the EditContactActivity class can read them<br />
j.putExtra("oldFirstName",selectedStudent.getFirstname());<br />
j.putExtra("oldLastName", selectedStudent.getLastName());<br />
j.putExtra("oldEmail",selectedStudent.getEmail());<br />
// Start the EditContactActivity activity<br />
startActivityForResult(j, EDIT_CONTACT);<br />
break;<br />
<br />
</source><br />
8.4.3 Modify the onActivityResult() method to accommodate the results of the EditContactActivity. Here is the completed code if this method:<br />
<source lang="java"><br />
@Override<br />
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {// modified to implement Edit<br />
switch (requestCode){<br />
case CREATE_CONTACT: // Add new Contact<br />
if (resultCode == Activity.RESULT_OK) {<br />
studentList.addElement(new Student(intent.getExtras().getString("firstName"),<br />
intent.getExtras().getString("lastName"), intent.getExtras().getString("email")));<br />
}<br />
else {<br />
showDialog("No contact was added!"); <br />
}<br />
displayData(studentList);<br />
break;<br />
case EDIT_CONTACT: // edit the selected Student<br />
// implement Edit<br />
if (resultCode == Activity.RESULT_OK) {<br />
Student oldS = selectedStudent;<br />
Student newS= new Student(intent.getExtras().getString("newFirstName"),<br />
intent.getExtras().getString("newLastName"),<br />
intent.getExtras().getString("newEmail"));<br />
for(int i = 0; i< studentList.size() ; i++){<br />
Student s= (Student)studentList.elementAt(i);<br />
if (s.getName().compareTo(oldS.getName())==0 && s.getEmail().compareTo(s.getEmail())==0){<br />
studentList.remove(s);<br />
studentList.add(newS);<br />
}<br />
<br />
}<br />
<br />
} else {<br />
showDialog("No contact was edited!");<br />
}<br />
displayData(studentList); <br />
<br />
break;<br />
default:<br />
break;<br />
}<br />
<br />
}<br />
<br />
</source><br />
<br />
===8.5 Edit Contact In action ===<br />
8.5.1 Build and run the project. Scrole mous buton to select a contact, and then click on the menu button of the virtual device. and then click on the EditContact menu option. Please note that the selected contact seems unselected but it's ok:<br/><br />
[[Image: editMenuOption.png | 450px]]<br/><br />
8.5.2 the Edit Contact view will apear with the selected student shown.<br/><br />
[[Image: editView.png | 450px]]<br/><br />
8.5.3 edit the Contact's info:<br/><br />
[[Image: editViewEdited.png | 450px]]<br/><br />
8.5.4 click on save contact button and see the result:<br/><br />
[[Image: editViewSaved.png | 450px]]<br/></div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/Android/Edit_Contact&diff=61900Teams Winter 2011/team1/Android/Edit Contact2011-04-07T17:35:52Z<p>Ladanzahir: /* 8.5 Edit Contact In action */</p>
<hr />
<div>== 8. Edit Contact ==<br />
===8.1 Create Edit Layout and Menu Item===<br />
8.1.1 Add the String value for the layout title to String.xml:===<br />
<source lang="java"><br />
<string name="editContact_textView">Edit Contact</string><br />
</source><br />
8.1.2 Right click on layout -> New -> Android XML File .<br/><br />
8.1.3 Enter edit.xml for the file name and check Layout:<br/><br />
8.1.4 Using Linear Layout, create this layout for editing contact information:<br/><br />
[[Image: editContactLayout.png | 250px]]<br/><br />
8.1.5 Here is the edit.xml implementation:<br />
<source lang="java"><br />
<?xml version="1.0" encoding="utf-8"?><br />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"<br />
android:layout_width="match_parent" android:layout_height="match_parent"<br />
android:orientation="vertical"><br />
<TextView android:layout_width="wrap_content"<br />
android:layout_height="wrap_content" android:id="@+id/titleTextViewEdit"<br />
android:gravity="center_vertical" android:textSize="30dp"<br />
android:layout_gravity="center" android:text="@string/editContact_textView"></TextView><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:layout_marginBottom="3dp" android:hint="@string/hint_first_name" android:id="@+id/firstNameEdit"></EditText><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:isScrollContainer="true"<br />
android:layout_marginBottom="3dp" android:hint="@string/hint_last_name" android:id="@+id/lastNameEdit"></EditText><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:layout_marginBottom="3dp" android:hint="@string/hint_email" android:id="@+id/emailEdit"></EditText><br />
<br />
<Button android:layout_width="wrap_content"<br />
android:layout_height="wrap_content" android:id="@+id/saveContact_buttonEdit"<br />
android:text="@string/saveButton" android:gravity="center_horizontal"<br />
android:layout_gravity="center_horizontal" android:textSize="20dp"></Button><br />
</LinearLayout><br />
</source><br />
8.1.6 Now Add the Edit menu Item. for this purpose click on menu.xml and brouse to the xml view, and add the menu item. Here is how it looks like:<br />
<source lang="java"><br />
<?xml version="1.0" encoding="utf-8"?><br />
<menu<br />
xmlns:android="http://schemas.android.com/apk/res/android"><br />
<item android:id="@+id/item1" android:title="Add Student"></item><br />
<item android:id="@+id/item2" android:title="Delete Student"></item><br />
<item android:id="@+id/item3" android:title="View Student"></item><br />
<item android:id="@+id/item4" android:title="Edit Student"></item><br />
<item android:id="@+id/item5" android:title="Send E-mail"></item><br />
</menu><br />
</source><br />
<br />
<br />
8.1.. Now build your project so that the ids are generated in R.java<br />
<br />
===8.2 Create EditContactActivity===<br />
8.2.1 Create the EditContactActivity in your package and make sure it extends Activity class.<br />
<source lang="java"><br />
package cs.ecl.team1.android;<br />
<br />
import android.app.Activity;<br />
public class AddContactActivity extends Activity {<br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
}<br />
}<br />
</source><br />
<br />
8.2.2 Add private fields:<br />
<source lang="java"><br />
private String firstName;<br />
private String lastName;<br />
private String email;<br />
</source><br />
8.2.3 Make sure that on creation it adds the edit layout to the view, so change the OnCreate method:<br />
<source lang="java"><br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.edit); // adds edit layout to view<br />
}<br />
}<br />
</source><br />
8.2.4 get the Intent of this Activity (later when starting this activity, we will send an Intent including the data of the selected student for editing). Then read he data from it and set the EditTexts values:<br />
<source lang="java"><br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.edit); // adds edit layout to view<br />
<br />
Intent i = this.getIntent(); // get this page intent<br />
<br />
// read the data from the Intent<br />
EditText fNameEditText = (EditText) findViewById(R.id.firstNameEdit);<br />
fNameEditText.setText(i.getStringExtra("oldFirstName"));<br />
<br />
EditText lNameEditText = (EditText) findViewById(R.id.lastNameEdit);<br />
lNameEditText.setText(i.getStringExtra("oldLastName"));<br />
<br />
EditText emailEditText = (EditText) findViewById(R.id.emailEdit);<br />
emailEditText.setText(i.getStringExtra("oldEmail"));<br />
<br />
<br />
}<br />
}<br />
</source><br />
<br />
8.2.5 Add and implement the save button: in the OnCreate method:<br />
<br />
<source lang="java"><br />
//save Button implementation<br />
Button saveButton = (Button) findViewById(R.id.saveContact_buttonEdit);<br />
saveButton.setOnClickListener(new OnClickListener() {<br />
public void onClick(View arg0) {<br />
firstName = ((EditText) findViewById(R.id.firstNameEdit)).getText().toString();<br />
lastName = ((EditText) findViewById(R.id.lastNameEdit)).getText().toString();<br />
email = ((EditText) findViewById(R.id.emailEdit)).getText().toString();<br />
<br />
finish();<br />
}<br />
});<br />
</source><br />
<br />
8.3.5 Now you need to override the finish() method:<br />
<source lang="java"><br />
@Override<br />
public void finish() {<br />
Intent i = new Intent();<br />
if (firstName.equals("") && lastName.equals("") && email.equals("")) {<br />
setResult(0);<br />
}<br />
else { // add the modified data to the intent<br />
i.putExtra("newFirstName", firstName);<br />
i.putExtra("newLastName", lastName);<br />
i.putExtra("newEmail", email);<br />
setResult(RESULT_OK, i);<br />
}<br />
super.finish();<br />
}<br />
</source><br />
8.3.6 Here is the completed source of the EditContactActivity:<br />
<source lang="java"><br />
package cs.ecl.team1.android;<br />
<br />
import android.app.Activity;<br />
import android.content.Intent;<br />
import android.os.Bundle;<br />
import android.view.View;<br />
import android.view.View.OnClickListener;<br />
import android.widget.Button;<br />
import android.widget.EditText;<br />
<br />
<br />
public class EditContactActivity extends Activity {<br />
private String firstName;<br />
private String lastName;<br />
private String email;<br />
<br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
<br />
setContentView(R.layout.edit);<br />
<br />
// get the intent sent to this class<br />
Intent i = this.getIntent();<br />
<br />
EditText fNameEditText = (EditText) findViewById(R.id.firstNameEdit);<br />
fNameEditText.setText(i.getStringExtra("oldFirstName"));<br />
<br />
EditText lNameEditText = (EditText) findViewById(R.id.lastNameEdit);<br />
lNameEditText.setText(i.getStringExtra("oldLastName"));<br />
<br />
EditText emailEditText = (EditText) findViewById(R.id.emailEdit);<br />
emailEditText.setText(i.getStringExtra("oldEmail"));<br />
<br />
<br />
//save Button implementation<br />
Button saveButton = (Button) findViewById(R.id.saveContact_buttonEdit);<br />
saveButton.setOnClickListener(new OnClickListener() {<br />
public void onClick(View arg0) {<br />
firstName = ((EditText) findViewById(R.id.firstNameEdit)).getText().toString();<br />
lastName = ((EditText) findViewById(R.id.lastNameEdit)).getText().toString();<br />
email = ((EditText) findViewById(R.id.emailEdit)).getText().toString();<br />
<br />
finish();<br />
}<br />
});<br />
}<br />
<br />
@Override<br />
public void finish() {<br />
Intent i = new Intent();<br />
if (firstName.equals("") && lastName.equals("") && email.equals("")) {<br />
setResult(0);<br />
}<br />
else {<br />
i.putExtra("newFirstName", firstName);<br />
i.putExtra("newLastName", lastName);<br />
i.putExtra("newEmail", email);<br />
setResult(RESULT_OK, i);<br />
}<br />
super.finish();<br />
}<br />
<br />
<br />
}<br />
<br />
</source><br />
<br />
===8.3 Add the EditContactActivity to the Android Manifest===<br />
Now we have to declare our EditContactActivity in the Manifest:<br />
open the AndroidManifest.xml and add this:<br />
<source lang="java"><br />
<activity android:label="Edit Contact" android:name="EditContactActivity"></activity><br />
</source><br />
<br />
===8.4 Implement the EditContact in the main activity class===<br />
8.4.1 Add the following private fields to the ContactList Activity :<br />
<source lang=java><br />
// added for Edit<br />
private static final int EDIT_CONTACT =1;<br />
private Student selectedStudent;<br />
<br />
</source><br />
<br />
8.4.2 In the onOptionsItemSelected(MenuItem item) method add the following case to the switch code block:<br />
<br />
<source lang="java"><br />
case R.id.item4:// Edit<br />
// set the private field :selectedStudent so that it can be accessed later<br />
selectedStudent = (Student)contactsList.getSelectedItem();<br />
// create an Intent for EditContactActivity class<br />
Intent j = new Intent(this, EditContactActivity.class);<br />
// add the selected student's data to the intent so that the EditContactActivity class can read them<br />
j.putExtra("oldFirstName",selectedStudent.getFirstname());<br />
j.putExtra("oldLastName", selectedStudent.getLastName());<br />
j.putExtra("oldEmail",selectedStudent.getEmail());<br />
// Start the EditContactActivity activity<br />
startActivityForResult(j, EDIT_CONTACT);<br />
break;<br />
<br />
</source><br />
8.4.3 Modify the onActivityResult() method to accommodate the results of the EditContactActivity. Here is the completed code if this method:<br />
<source lang="java"><br />
@Override<br />
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {// modified to implement Edit<br />
switch (requestCode){<br />
case CREATE_CONTACT: // Add new Contact<br />
if (resultCode == Activity.RESULT_OK) {<br />
studentList.addElement(new Student(intent.getExtras().getString("firstName"),<br />
intent.getExtras().getString("lastName"), intent.getExtras().getString("email")));<br />
}<br />
else {<br />
showDialog("No contact was added!"); <br />
}<br />
displayData(studentList);<br />
break;<br />
case EDIT_CONTACT: // edit the selected Student<br />
// implement Edit<br />
if (resultCode == Activity.RESULT_OK) {<br />
Student oldS = selectedStudent;<br />
Student newS= new Student(intent.getExtras().getString("newFirstName"),<br />
intent.getExtras().getString("newLastName"),<br />
intent.getExtras().getString("newEmail"));<br />
for(int i = 0; i< studentList.size() ; i++){<br />
Student s= (Student)studentList.elementAt(i);<br />
if (s.getName().compareTo(oldS.getName())==0 && s.getEmail().compareTo(s.getEmail())==0){<br />
studentList.remove(s);<br />
studentList.add(newS);<br />
}<br />
<br />
}<br />
<br />
} else {<br />
showDialog("No contact was edited!");<br />
}<br />
displayData(studentList); <br />
<br />
break;<br />
default:<br />
break;<br />
}<br />
<br />
}<br />
<br />
</source><br />
<br />
===8.5 Edit Contact In action ===<br />
8.5.1 Build and run the project. Scrole mous buton to select a contact, and then click on the menu button of the virtual device. and then click on the EditContact menu option. Please note that the selected contact seems unselected but it's ok:<br/><br />
[[Image: editMenuOption.png | 450px]]<br/><br />
8.5.2 the Edit Contact view will apear with the selected student shown.<br/><br />
[[Image: editView.png | 450px]]<br/><br />
8.5.3 edit the Contact's info:<br/><br />
[[Image: editViewEdited.png | 450px]]<br/><br />
8.5.4 click on save contact button and see the result:<br/><br />
[[Image: editViewSaved.png | 450px]]<br/></div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/Android/Edit_Contact&diff=61899Teams Winter 2011/team1/Android/Edit Contact2011-04-07T17:32:18Z<p>Ladanzahir: /* 8.1 Create Edit Layout */</p>
<hr />
<div>== 8. Edit Contact ==<br />
===8.1 Create Edit Layout and Menu Item===<br />
8.1.1 Add the String value for the layout title to String.xml:===<br />
<source lang="java"><br />
<string name="editContact_textView">Edit Contact</string><br />
</source><br />
8.1.2 Right click on layout -> New -> Android XML File .<br/><br />
8.1.3 Enter edit.xml for the file name and check Layout:<br/><br />
8.1.4 Using Linear Layout, create this layout for editing contact information:<br/><br />
[[Image: editContactLayout.png | 250px]]<br/><br />
8.1.5 Here is the edit.xml implementation:<br />
<source lang="java"><br />
<?xml version="1.0" encoding="utf-8"?><br />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"<br />
android:layout_width="match_parent" android:layout_height="match_parent"<br />
android:orientation="vertical"><br />
<TextView android:layout_width="wrap_content"<br />
android:layout_height="wrap_content" android:id="@+id/titleTextViewEdit"<br />
android:gravity="center_vertical" android:textSize="30dp"<br />
android:layout_gravity="center" android:text="@string/editContact_textView"></TextView><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:layout_marginBottom="3dp" android:hint="@string/hint_first_name" android:id="@+id/firstNameEdit"></EditText><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:isScrollContainer="true"<br />
android:layout_marginBottom="3dp" android:hint="@string/hint_last_name" android:id="@+id/lastNameEdit"></EditText><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:layout_marginBottom="3dp" android:hint="@string/hint_email" android:id="@+id/emailEdit"></EditText><br />
<br />
<Button android:layout_width="wrap_content"<br />
android:layout_height="wrap_content" android:id="@+id/saveContact_buttonEdit"<br />
android:text="@string/saveButton" android:gravity="center_horizontal"<br />
android:layout_gravity="center_horizontal" android:textSize="20dp"></Button><br />
</LinearLayout><br />
</source><br />
8.1.6 Now Add the Edit menu Item. for this purpose click on menu.xml and brouse to the xml view, and add the menu item. Here is how it looks like:<br />
<source lang="java"><br />
<?xml version="1.0" encoding="utf-8"?><br />
<menu<br />
xmlns:android="http://schemas.android.com/apk/res/android"><br />
<item android:id="@+id/item1" android:title="Add Student"></item><br />
<item android:id="@+id/item2" android:title="Delete Student"></item><br />
<item android:id="@+id/item3" android:title="View Student"></item><br />
<item android:id="@+id/item4" android:title="Edit Student"></item><br />
<item android:id="@+id/item5" android:title="Send E-mail"></item><br />
</menu><br />
</source><br />
<br />
<br />
8.1.. Now build your project so that the ids are generated in R.java<br />
<br />
===8.2 Create EditContactActivity===<br />
8.2.1 Create the EditContactActivity in your package and make sure it extends Activity class.<br />
<source lang="java"><br />
package cs.ecl.team1.android;<br />
<br />
import android.app.Activity;<br />
public class AddContactActivity extends Activity {<br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
}<br />
}<br />
</source><br />
<br />
8.2.2 Add private fields:<br />
<source lang="java"><br />
private String firstName;<br />
private String lastName;<br />
private String email;<br />
</source><br />
8.2.3 Make sure that on creation it adds the edit layout to the view, so change the OnCreate method:<br />
<source lang="java"><br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.edit); // adds edit layout to view<br />
}<br />
}<br />
</source><br />
8.2.4 get the Intent of this Activity (later when starting this activity, we will send an Intent including the data of the selected student for editing). Then read he data from it and set the EditTexts values:<br />
<source lang="java"><br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.edit); // adds edit layout to view<br />
<br />
Intent i = this.getIntent(); // get this page intent<br />
<br />
// read the data from the Intent<br />
EditText fNameEditText = (EditText) findViewById(R.id.firstNameEdit);<br />
fNameEditText.setText(i.getStringExtra("oldFirstName"));<br />
<br />
EditText lNameEditText = (EditText) findViewById(R.id.lastNameEdit);<br />
lNameEditText.setText(i.getStringExtra("oldLastName"));<br />
<br />
EditText emailEditText = (EditText) findViewById(R.id.emailEdit);<br />
emailEditText.setText(i.getStringExtra("oldEmail"));<br />
<br />
<br />
}<br />
}<br />
</source><br />
<br />
8.2.5 Add and implement the save button: in the OnCreate method:<br />
<br />
<source lang="java"><br />
//save Button implementation<br />
Button saveButton = (Button) findViewById(R.id.saveContact_buttonEdit);<br />
saveButton.setOnClickListener(new OnClickListener() {<br />
public void onClick(View arg0) {<br />
firstName = ((EditText) findViewById(R.id.firstNameEdit)).getText().toString();<br />
lastName = ((EditText) findViewById(R.id.lastNameEdit)).getText().toString();<br />
email = ((EditText) findViewById(R.id.emailEdit)).getText().toString();<br />
<br />
finish();<br />
}<br />
});<br />
</source><br />
<br />
8.3.5 Now you need to override the finish() method:<br />
<source lang="java"><br />
@Override<br />
public void finish() {<br />
Intent i = new Intent();<br />
if (firstName.equals("") && lastName.equals("") && email.equals("")) {<br />
setResult(0);<br />
}<br />
else { // add the modified data to the intent<br />
i.putExtra("newFirstName", firstName);<br />
i.putExtra("newLastName", lastName);<br />
i.putExtra("newEmail", email);<br />
setResult(RESULT_OK, i);<br />
}<br />
super.finish();<br />
}<br />
</source><br />
8.3.6 Here is the completed source of the EditContactActivity:<br />
<source lang="java"><br />
package cs.ecl.team1.android;<br />
<br />
import android.app.Activity;<br />
import android.content.Intent;<br />
import android.os.Bundle;<br />
import android.view.View;<br />
import android.view.View.OnClickListener;<br />
import android.widget.Button;<br />
import android.widget.EditText;<br />
<br />
<br />
public class EditContactActivity extends Activity {<br />
private String firstName;<br />
private String lastName;<br />
private String email;<br />
<br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
<br />
setContentView(R.layout.edit);<br />
<br />
// get the intent sent to this class<br />
Intent i = this.getIntent();<br />
<br />
EditText fNameEditText = (EditText) findViewById(R.id.firstNameEdit);<br />
fNameEditText.setText(i.getStringExtra("oldFirstName"));<br />
<br />
EditText lNameEditText = (EditText) findViewById(R.id.lastNameEdit);<br />
lNameEditText.setText(i.getStringExtra("oldLastName"));<br />
<br />
EditText emailEditText = (EditText) findViewById(R.id.emailEdit);<br />
emailEditText.setText(i.getStringExtra("oldEmail"));<br />
<br />
<br />
//save Button implementation<br />
Button saveButton = (Button) findViewById(R.id.saveContact_buttonEdit);<br />
saveButton.setOnClickListener(new OnClickListener() {<br />
public void onClick(View arg0) {<br />
firstName = ((EditText) findViewById(R.id.firstNameEdit)).getText().toString();<br />
lastName = ((EditText) findViewById(R.id.lastNameEdit)).getText().toString();<br />
email = ((EditText) findViewById(R.id.emailEdit)).getText().toString();<br />
<br />
finish();<br />
}<br />
});<br />
}<br />
<br />
@Override<br />
public void finish() {<br />
Intent i = new Intent();<br />
if (firstName.equals("") && lastName.equals("") && email.equals("")) {<br />
setResult(0);<br />
}<br />
else {<br />
i.putExtra("newFirstName", firstName);<br />
i.putExtra("newLastName", lastName);<br />
i.putExtra("newEmail", email);<br />
setResult(RESULT_OK, i);<br />
}<br />
super.finish();<br />
}<br />
<br />
<br />
}<br />
<br />
</source><br />
<br />
===8.3 Add the EditContactActivity to the Android Manifest===<br />
Now we have to declare our EditContactActivity in the Manifest:<br />
open the AndroidManifest.xml and add this:<br />
<source lang="java"><br />
<activity android:label="Edit Contact" android:name="EditContactActivity"></activity><br />
</source><br />
<br />
===8.4 Implement the EditContact in the main activity class===<br />
8.4.1 Add the following private fields to the ContactList Activity :<br />
<source lang=java><br />
// added for Edit<br />
private static final int EDIT_CONTACT =1;<br />
private Student selectedStudent;<br />
<br />
</source><br />
<br />
8.4.2 In the onOptionsItemSelected(MenuItem item) method add the following case to the switch code block:<br />
<br />
<source lang="java"><br />
case R.id.item4:// Edit<br />
// set the private field :selectedStudent so that it can be accessed later<br />
selectedStudent = (Student)contactsList.getSelectedItem();<br />
// create an Intent for EditContactActivity class<br />
Intent j = new Intent(this, EditContactActivity.class);<br />
// add the selected student's data to the intent so that the EditContactActivity class can read them<br />
j.putExtra("oldFirstName",selectedStudent.getFirstname());<br />
j.putExtra("oldLastName", selectedStudent.getLastName());<br />
j.putExtra("oldEmail",selectedStudent.getEmail());<br />
// Start the EditContactActivity activity<br />
startActivityForResult(j, EDIT_CONTACT);<br />
break;<br />
<br />
</source><br />
8.4.3 Modify the onActivityResult() method to accommodate the results of the EditContactActivity. Here is the completed code if this method:<br />
<source lang="java"><br />
@Override<br />
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {// modified to implement Edit<br />
switch (requestCode){<br />
case CREATE_CONTACT: // Add new Contact<br />
if (resultCode == Activity.RESULT_OK) {<br />
studentList.addElement(new Student(intent.getExtras().getString("firstName"),<br />
intent.getExtras().getString("lastName"), intent.getExtras().getString("email")));<br />
}<br />
else {<br />
showDialog("No contact was added!"); <br />
}<br />
displayData(studentList);<br />
break;<br />
case EDIT_CONTACT: // edit the selected Student<br />
// implement Edit<br />
if (resultCode == Activity.RESULT_OK) {<br />
Student oldS = selectedStudent;<br />
Student newS= new Student(intent.getExtras().getString("newFirstName"),<br />
intent.getExtras().getString("newLastName"),<br />
intent.getExtras().getString("newEmail"));<br />
for(int i = 0; i< studentList.size() ; i++){<br />
Student s= (Student)studentList.elementAt(i);<br />
if (s.getName().compareTo(oldS.getName())==0 && s.getEmail().compareTo(s.getEmail())==0){<br />
studentList.remove(s);<br />
studentList.add(newS);<br />
}<br />
<br />
}<br />
<br />
} else {<br />
showDialog("No contact was edited!");<br />
}<br />
displayData(studentList); <br />
<br />
break;<br />
default:<br />
break;<br />
}<br />
<br />
}<br />
<br />
</source><br />
<br />
===8.5 Edit Contact In action ===<br />
8.5.1 Build and run the project. Scrole mous buton to select a contact, and then click on the menu button of the virtual device. and then click on the EditContact menu option. Please note that the selected contact seems unselected but it's ok:<br/><br />
[[Image: editMenuOption.png | 450px]]<br/><br />
8.5.2 the Edit Contact view will apear with the selected student shown<br/><br />
[[Image: editView.png | 450px]]<br/><br />
8.5.3 edit the Contact's info:<br/><br />
[[Image: editViewEdited.png | 450px]]<br/><br />
8.5.4 click on save contact button and see the result:<br/><br />
[[Image: editViewSaved.png | 450px]]<br/></div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/Android/Edit_Contact&diff=61894Teams Winter 2011/team1/Android/Edit Contact2011-04-07T17:05:10Z<p>Ladanzahir: /* 8.5 Edit Contact In action */</p>
<hr />
<div>== 8. Edit Contact ==<br />
===8.1 Create Edit Layout===<br />
8.1.1 Add the String value for the layout title to String.xml:===<br />
<source lang="java"><br />
<string name="editContact_textView">Edit Contact</string><br />
</source><br />
8.1.2 Right click on layout -> New -> Android XML File .<br/><br />
8.1.3 Enter edit.xml for the file name and check Layout:<br/><br />
8.1.4 Using Linear Layout, create this layout for editing contact information:<br/><br />
[[Image: editContactLayout.png | 250px]]<br/><br />
8.1.5 Here is the edit.xml implementation:<br />
<source lang="java"><br />
<?xml version="1.0" encoding="utf-8"?><br />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"<br />
android:layout_width="match_parent" android:layout_height="match_parent"<br />
android:orientation="vertical"><br />
<TextView android:layout_width="wrap_content"<br />
android:layout_height="wrap_content" android:id="@+id/titleTextViewEdit"<br />
android:gravity="center_vertical" android:textSize="30dp"<br />
android:layout_gravity="center" android:text="@string/editContact_textView"></TextView><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:layout_marginBottom="3dp" android:hint="@string/hint_first_name" android:id="@+id/firstNameEdit"></EditText><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:isScrollContainer="true"<br />
android:layout_marginBottom="3dp" android:hint="@string/hint_last_name" android:id="@+id/lastNameEdit"></EditText><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:layout_marginBottom="3dp" android:hint="@string/hint_email" android:id="@+id/emailEdit"></EditText><br />
<br />
<Button android:layout_width="wrap_content"<br />
android:layout_height="wrap_content" android:id="@+id/saveContact_buttonEdit"<br />
android:text="@string/saveButton" android:gravity="center_horizontal"<br />
android:layout_gravity="center_horizontal" android:textSize="20dp"></Button><br />
</LinearLayout><br />
</source><br />
8.1.6. Now build your project so that the ids are generated in R.java<br />
<br />
===8.2 Create EditContactActivity===<br />
8.2.1 Create the EditContactActivity in your package and make sure it extends Activity class.<br />
<source lang="java"><br />
package cs.ecl.team1.android;<br />
<br />
import android.app.Activity;<br />
public class AddContactActivity extends Activity {<br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
}<br />
}<br />
</source><br />
<br />
8.2.2 Add private fields:<br />
<source lang="java"><br />
private String firstName;<br />
private String lastName;<br />
private String email;<br />
</source><br />
8.2.3 Make sure that on creation it adds the edit layout to the view, so change the OnCreate method:<br />
<source lang="java"><br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.edit); // adds edit layout to view<br />
}<br />
}<br />
</source><br />
8.2.4 get the Intent of this Activity (later when starting this activity, we will send an Intent including the data of the selected student for editing). Then read he data from it and set the EditTexts values:<br />
<source lang="java"><br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.edit); // adds edit layout to view<br />
<br />
Intent i = this.getIntent(); // get this page intent<br />
<br />
// read the data from the Intent<br />
EditText fNameEditText = (EditText) findViewById(R.id.firstNameEdit);<br />
fNameEditText.setText(i.getStringExtra("oldFirstName"));<br />
<br />
EditText lNameEditText = (EditText) findViewById(R.id.lastNameEdit);<br />
lNameEditText.setText(i.getStringExtra("oldLastName"));<br />
<br />
EditText emailEditText = (EditText) findViewById(R.id.emailEdit);<br />
emailEditText.setText(i.getStringExtra("oldEmail"));<br />
<br />
<br />
}<br />
}<br />
</source><br />
<br />
8.2.5 Add and implement the save button: in the OnCreate method:<br />
<br />
<source lang="java"><br />
//save Button implementation<br />
Button saveButton = (Button) findViewById(R.id.saveContact_buttonEdit);<br />
saveButton.setOnClickListener(new OnClickListener() {<br />
public void onClick(View arg0) {<br />
firstName = ((EditText) findViewById(R.id.firstNameEdit)).getText().toString();<br />
lastName = ((EditText) findViewById(R.id.lastNameEdit)).getText().toString();<br />
email = ((EditText) findViewById(R.id.emailEdit)).getText().toString();<br />
<br />
finish();<br />
}<br />
});<br />
</source><br />
<br />
8.3.5 Now you need to override the finish() method:<br />
<source lang="java"><br />
@Override<br />
public void finish() {<br />
Intent i = new Intent();<br />
if (firstName.equals("") && lastName.equals("") && email.equals("")) {<br />
setResult(0);<br />
}<br />
else { // add the modified data to the intent<br />
i.putExtra("newFirstName", firstName);<br />
i.putExtra("newLastName", lastName);<br />
i.putExtra("newEmail", email);<br />
setResult(RESULT_OK, i);<br />
}<br />
super.finish();<br />
}<br />
</source><br />
8.3.6 Here is the completed source of the EditContactActivity:<br />
<source lang="java"><br />
package cs.ecl.team1.android;<br />
<br />
import android.app.Activity;<br />
import android.content.Intent;<br />
import android.os.Bundle;<br />
import android.view.View;<br />
import android.view.View.OnClickListener;<br />
import android.widget.Button;<br />
import android.widget.EditText;<br />
<br />
<br />
public class EditContactActivity extends Activity {<br />
private String firstName;<br />
private String lastName;<br />
private String email;<br />
<br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
<br />
setContentView(R.layout.edit);<br />
<br />
// get the intent sent to this class<br />
Intent i = this.getIntent();<br />
<br />
EditText fNameEditText = (EditText) findViewById(R.id.firstNameEdit);<br />
fNameEditText.setText(i.getStringExtra("oldFirstName"));<br />
<br />
EditText lNameEditText = (EditText) findViewById(R.id.lastNameEdit);<br />
lNameEditText.setText(i.getStringExtra("oldLastName"));<br />
<br />
EditText emailEditText = (EditText) findViewById(R.id.emailEdit);<br />
emailEditText.setText(i.getStringExtra("oldEmail"));<br />
<br />
<br />
//save Button implementation<br />
Button saveButton = (Button) findViewById(R.id.saveContact_buttonEdit);<br />
saveButton.setOnClickListener(new OnClickListener() {<br />
public void onClick(View arg0) {<br />
firstName = ((EditText) findViewById(R.id.firstNameEdit)).getText().toString();<br />
lastName = ((EditText) findViewById(R.id.lastNameEdit)).getText().toString();<br />
email = ((EditText) findViewById(R.id.emailEdit)).getText().toString();<br />
<br />
finish();<br />
}<br />
});<br />
}<br />
<br />
@Override<br />
public void finish() {<br />
Intent i = new Intent();<br />
if (firstName.equals("") && lastName.equals("") && email.equals("")) {<br />
setResult(0);<br />
}<br />
else {<br />
i.putExtra("newFirstName", firstName);<br />
i.putExtra("newLastName", lastName);<br />
i.putExtra("newEmail", email);<br />
setResult(RESULT_OK, i);<br />
}<br />
super.finish();<br />
}<br />
<br />
<br />
}<br />
<br />
</source><br />
<br />
===8.3 Add the EditContactActivity to the Android Manifest===<br />
Now we have to declare our EditContactActivity in the Manifest:<br />
open the AndroidManifest.xml and add this:<br />
<source lang="java"><br />
<activity android:label="Edit Contact" android:name="EditContactActivity"></activity><br />
</source><br />
<br />
===8.4 Implement the EditContact in the main activity class===<br />
8.4.1 Add the following private fields to the ContactList Activity :<br />
<source lang=java><br />
// added for Edit<br />
private static final int EDIT_CONTACT =1;<br />
private Student selectedStudent;<br />
<br />
</source><br />
<br />
8.4.2 In the onOptionsItemSelected(MenuItem item) method add the following case to the switch code block:<br />
<br />
<source lang="java"><br />
case R.id.item4:// Edit<br />
// set the private field :selectedStudent so that it can be accessed later<br />
selectedStudent = (Student)contactsList.getSelectedItem();<br />
// create an Intent for EditContactActivity class<br />
Intent j = new Intent(this, EditContactActivity.class);<br />
// add the selected student's data to the intent so that the EditContactActivity class can read them<br />
j.putExtra("oldFirstName",selectedStudent.getFirstname());<br />
j.putExtra("oldLastName", selectedStudent.getLastName());<br />
j.putExtra("oldEmail",selectedStudent.getEmail());<br />
// Start the EditContactActivity activity<br />
startActivityForResult(j, EDIT_CONTACT);<br />
break;<br />
<br />
</source><br />
8.4.3 Modify the onActivityResult() method to accommodate the results of the EditContactActivity. Here is the completed code if this method:<br />
<source lang="java"><br />
@Override<br />
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {// modified to implement Edit<br />
switch (requestCode){<br />
case CREATE_CONTACT: // Add new Contact<br />
if (resultCode == Activity.RESULT_OK) {<br />
studentList.addElement(new Student(intent.getExtras().getString("firstName"),<br />
intent.getExtras().getString("lastName"), intent.getExtras().getString("email")));<br />
}<br />
else {<br />
showDialog("No contact was added!"); <br />
}<br />
displayData(studentList);<br />
break;<br />
case EDIT_CONTACT: // edit the selected Student<br />
// implement Edit<br />
if (resultCode == Activity.RESULT_OK) {<br />
Student oldS = selectedStudent;<br />
Student newS= new Student(intent.getExtras().getString("newFirstName"),<br />
intent.getExtras().getString("newLastName"),<br />
intent.getExtras().getString("newEmail"));<br />
for(int i = 0; i< studentList.size() ; i++){<br />
Student s= (Student)studentList.elementAt(i);<br />
if (s.getName().compareTo(oldS.getName())==0 && s.getEmail().compareTo(s.getEmail())==0){<br />
studentList.remove(s);<br />
studentList.add(newS);<br />
}<br />
<br />
}<br />
<br />
} else {<br />
showDialog("No contact was edited!");<br />
}<br />
displayData(studentList); <br />
<br />
break;<br />
default:<br />
break;<br />
}<br />
<br />
}<br />
<br />
</source><br />
<br />
===8.5 Edit Contact In action ===<br />
8.5.1 Build and run the project. Scrole mous buton to select a contact, and then click on the menu button of the virtual device. and then click on the EditContact menu option. Please note that the selected contact seems unselected but it's ok:<br/><br />
[[Image: editMenuOption.png | 450px]]<br/><br />
8.5.2 the Edit Contact view will apear with the selected student shown<br/><br />
[[Image: editView.png | 450px]]<br/><br />
8.5.3 edit the Contact's info:<br/><br />
[[Image: editViewEdited.png | 450px]]<br/><br />
8.5.4 click on save contact button and see the result:<br/><br />
[[Image: editViewSaved.png | 450px]]<br/></div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/Android/Edit_Contact&diff=61893Teams Winter 2011/team1/Android/Edit Contact2011-04-07T17:02:09Z<p>Ladanzahir: /* 8.5 Edit Contact In action */</p>
<hr />
<div>== 8. Edit Contact ==<br />
===8.1 Create Edit Layout===<br />
8.1.1 Add the String value for the layout title to String.xml:===<br />
<source lang="java"><br />
<string name="editContact_textView">Edit Contact</string><br />
</source><br />
8.1.2 Right click on layout -> New -> Android XML File .<br/><br />
8.1.3 Enter edit.xml for the file name and check Layout:<br/><br />
8.1.4 Using Linear Layout, create this layout for editing contact information:<br/><br />
[[Image: editContactLayout.png | 250px]]<br/><br />
8.1.5 Here is the edit.xml implementation:<br />
<source lang="java"><br />
<?xml version="1.0" encoding="utf-8"?><br />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"<br />
android:layout_width="match_parent" android:layout_height="match_parent"<br />
android:orientation="vertical"><br />
<TextView android:layout_width="wrap_content"<br />
android:layout_height="wrap_content" android:id="@+id/titleTextViewEdit"<br />
android:gravity="center_vertical" android:textSize="30dp"<br />
android:layout_gravity="center" android:text="@string/editContact_textView"></TextView><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:layout_marginBottom="3dp" android:hint="@string/hint_first_name" android:id="@+id/firstNameEdit"></EditText><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:isScrollContainer="true"<br />
android:layout_marginBottom="3dp" android:hint="@string/hint_last_name" android:id="@+id/lastNameEdit"></EditText><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:layout_marginBottom="3dp" android:hint="@string/hint_email" android:id="@+id/emailEdit"></EditText><br />
<br />
<Button android:layout_width="wrap_content"<br />
android:layout_height="wrap_content" android:id="@+id/saveContact_buttonEdit"<br />
android:text="@string/saveButton" android:gravity="center_horizontal"<br />
android:layout_gravity="center_horizontal" android:textSize="20dp"></Button><br />
</LinearLayout><br />
</source><br />
8.1.6. Now build your project so that the ids are generated in R.java<br />
<br />
===8.2 Create EditContactActivity===<br />
8.2.1 Create the EditContactActivity in your package and make sure it extends Activity class.<br />
<source lang="java"><br />
package cs.ecl.team1.android;<br />
<br />
import android.app.Activity;<br />
public class AddContactActivity extends Activity {<br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
}<br />
}<br />
</source><br />
<br />
8.2.2 Add private fields:<br />
<source lang="java"><br />
private String firstName;<br />
private String lastName;<br />
private String email;<br />
</source><br />
8.2.3 Make sure that on creation it adds the edit layout to the view, so change the OnCreate method:<br />
<source lang="java"><br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.edit); // adds edit layout to view<br />
}<br />
}<br />
</source><br />
8.2.4 get the Intent of this Activity (later when starting this activity, we will send an Intent including the data of the selected student for editing). Then read he data from it and set the EditTexts values:<br />
<source lang="java"><br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.edit); // adds edit layout to view<br />
<br />
Intent i = this.getIntent(); // get this page intent<br />
<br />
// read the data from the Intent<br />
EditText fNameEditText = (EditText) findViewById(R.id.firstNameEdit);<br />
fNameEditText.setText(i.getStringExtra("oldFirstName"));<br />
<br />
EditText lNameEditText = (EditText) findViewById(R.id.lastNameEdit);<br />
lNameEditText.setText(i.getStringExtra("oldLastName"));<br />
<br />
EditText emailEditText = (EditText) findViewById(R.id.emailEdit);<br />
emailEditText.setText(i.getStringExtra("oldEmail"));<br />
<br />
<br />
}<br />
}<br />
</source><br />
<br />
8.2.5 Add and implement the save button: in the OnCreate method:<br />
<br />
<source lang="java"><br />
//save Button implementation<br />
Button saveButton = (Button) findViewById(R.id.saveContact_buttonEdit);<br />
saveButton.setOnClickListener(new OnClickListener() {<br />
public void onClick(View arg0) {<br />
firstName = ((EditText) findViewById(R.id.firstNameEdit)).getText().toString();<br />
lastName = ((EditText) findViewById(R.id.lastNameEdit)).getText().toString();<br />
email = ((EditText) findViewById(R.id.emailEdit)).getText().toString();<br />
<br />
finish();<br />
}<br />
});<br />
</source><br />
<br />
8.3.5 Now you need to override the finish() method:<br />
<source lang="java"><br />
@Override<br />
public void finish() {<br />
Intent i = new Intent();<br />
if (firstName.equals("") && lastName.equals("") && email.equals("")) {<br />
setResult(0);<br />
}<br />
else { // add the modified data to the intent<br />
i.putExtra("newFirstName", firstName);<br />
i.putExtra("newLastName", lastName);<br />
i.putExtra("newEmail", email);<br />
setResult(RESULT_OK, i);<br />
}<br />
super.finish();<br />
}<br />
</source><br />
8.3.6 Here is the completed source of the EditContactActivity:<br />
<source lang="java"><br />
package cs.ecl.team1.android;<br />
<br />
import android.app.Activity;<br />
import android.content.Intent;<br />
import android.os.Bundle;<br />
import android.view.View;<br />
import android.view.View.OnClickListener;<br />
import android.widget.Button;<br />
import android.widget.EditText;<br />
<br />
<br />
public class EditContactActivity extends Activity {<br />
private String firstName;<br />
private String lastName;<br />
private String email;<br />
<br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
<br />
setContentView(R.layout.edit);<br />
<br />
// get the intent sent to this class<br />
Intent i = this.getIntent();<br />
<br />
EditText fNameEditText = (EditText) findViewById(R.id.firstNameEdit);<br />
fNameEditText.setText(i.getStringExtra("oldFirstName"));<br />
<br />
EditText lNameEditText = (EditText) findViewById(R.id.lastNameEdit);<br />
lNameEditText.setText(i.getStringExtra("oldLastName"));<br />
<br />
EditText emailEditText = (EditText) findViewById(R.id.emailEdit);<br />
emailEditText.setText(i.getStringExtra("oldEmail"));<br />
<br />
<br />
//save Button implementation<br />
Button saveButton = (Button) findViewById(R.id.saveContact_buttonEdit);<br />
saveButton.setOnClickListener(new OnClickListener() {<br />
public void onClick(View arg0) {<br />
firstName = ((EditText) findViewById(R.id.firstNameEdit)).getText().toString();<br />
lastName = ((EditText) findViewById(R.id.lastNameEdit)).getText().toString();<br />
email = ((EditText) findViewById(R.id.emailEdit)).getText().toString();<br />
<br />
finish();<br />
}<br />
});<br />
}<br />
<br />
@Override<br />
public void finish() {<br />
Intent i = new Intent();<br />
if (firstName.equals("") && lastName.equals("") && email.equals("")) {<br />
setResult(0);<br />
}<br />
else {<br />
i.putExtra("newFirstName", firstName);<br />
i.putExtra("newLastName", lastName);<br />
i.putExtra("newEmail", email);<br />
setResult(RESULT_OK, i);<br />
}<br />
super.finish();<br />
}<br />
<br />
<br />
}<br />
<br />
</source><br />
<br />
===8.3 Add the EditContactActivity to the Android Manifest===<br />
Now we have to declare our EditContactActivity in the Manifest:<br />
open the AndroidManifest.xml and add this:<br />
<source lang="java"><br />
<activity android:label="Edit Contact" android:name="EditContactActivity"></activity><br />
</source><br />
<br />
===8.4 Implement the EditContact in the main activity class===<br />
8.4.1 Add the following private fields to the ContactList Activity :<br />
<source lang=java><br />
// added for Edit<br />
private static final int EDIT_CONTACT =1;<br />
private Student selectedStudent;<br />
<br />
</source><br />
<br />
8.4.2 In the onOptionsItemSelected(MenuItem item) method add the following case to the switch code block:<br />
<br />
<source lang="java"><br />
case R.id.item4:// Edit<br />
// set the private field :selectedStudent so that it can be accessed later<br />
selectedStudent = (Student)contactsList.getSelectedItem();<br />
// create an Intent for EditContactActivity class<br />
Intent j = new Intent(this, EditContactActivity.class);<br />
// add the selected student's data to the intent so that the EditContactActivity class can read them<br />
j.putExtra("oldFirstName",selectedStudent.getFirstname());<br />
j.putExtra("oldLastName", selectedStudent.getLastName());<br />
j.putExtra("oldEmail",selectedStudent.getEmail());<br />
// Start the EditContactActivity activity<br />
startActivityForResult(j, EDIT_CONTACT);<br />
break;<br />
<br />
</source><br />
8.4.3 Modify the onActivityResult() method to accommodate the results of the EditContactActivity. Here is the completed code if this method:<br />
<source lang="java"><br />
@Override<br />
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {// modified to implement Edit<br />
switch (requestCode){<br />
case CREATE_CONTACT: // Add new Contact<br />
if (resultCode == Activity.RESULT_OK) {<br />
studentList.addElement(new Student(intent.getExtras().getString("firstName"),<br />
intent.getExtras().getString("lastName"), intent.getExtras().getString("email")));<br />
}<br />
else {<br />
showDialog("No contact was added!"); <br />
}<br />
displayData(studentList);<br />
break;<br />
case EDIT_CONTACT: // edit the selected Student<br />
// implement Edit<br />
if (resultCode == Activity.RESULT_OK) {<br />
Student oldS = selectedStudent;<br />
Student newS= new Student(intent.getExtras().getString("newFirstName"),<br />
intent.getExtras().getString("newLastName"),<br />
intent.getExtras().getString("newEmail"));<br />
for(int i = 0; i< studentList.size() ; i++){<br />
Student s= (Student)studentList.elementAt(i);<br />
if (s.getName().compareTo(oldS.getName())==0 && s.getEmail().compareTo(s.getEmail())==0){<br />
studentList.remove(s);<br />
studentList.add(newS);<br />
}<br />
<br />
}<br />
<br />
} else {<br />
showDialog("No contact was edited!");<br />
}<br />
displayData(studentList); <br />
<br />
break;<br />
default:<br />
break;<br />
}<br />
<br />
}<br />
<br />
</source><br />
<br />
===8.5 Edit Contact In action ===<br />
8.5.1 Build and run the project. Scrole mous buton to select a contact, and then click on the menu button of the virtual device. and then click on the EditContact menu option. Please note that the selected contact seems unselected but it's ok:<br/><br />
[[Image: editMenuOption.png | 450px]]<br/><br />
8.5.2<br />
[[Image: editView.png | 450px]]<br/><br />
[[Image: editViewEdited.png | 450px]]<br/><br />
[[Image: editViewSaved.png | 450px]]<br/></div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/Android/Edit_Contact&diff=61892Teams Winter 2011/team1/Android/Edit Contact2011-04-07T17:01:23Z<p>Ladanzahir: /* 8.5 Edit Contact In action */</p>
<hr />
<div>== 8. Edit Contact ==<br />
===8.1 Create Edit Layout===<br />
8.1.1 Add the String value for the layout title to String.xml:===<br />
<source lang="java"><br />
<string name="editContact_textView">Edit Contact</string><br />
</source><br />
8.1.2 Right click on layout -> New -> Android XML File .<br/><br />
8.1.3 Enter edit.xml for the file name and check Layout:<br/><br />
8.1.4 Using Linear Layout, create this layout for editing contact information:<br/><br />
[[Image: editContactLayout.png | 250px]]<br/><br />
8.1.5 Here is the edit.xml implementation:<br />
<source lang="java"><br />
<?xml version="1.0" encoding="utf-8"?><br />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"<br />
android:layout_width="match_parent" android:layout_height="match_parent"<br />
android:orientation="vertical"><br />
<TextView android:layout_width="wrap_content"<br />
android:layout_height="wrap_content" android:id="@+id/titleTextViewEdit"<br />
android:gravity="center_vertical" android:textSize="30dp"<br />
android:layout_gravity="center" android:text="@string/editContact_textView"></TextView><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:layout_marginBottom="3dp" android:hint="@string/hint_first_name" android:id="@+id/firstNameEdit"></EditText><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:isScrollContainer="true"<br />
android:layout_marginBottom="3dp" android:hint="@string/hint_last_name" android:id="@+id/lastNameEdit"></EditText><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:layout_marginBottom="3dp" android:hint="@string/hint_email" android:id="@+id/emailEdit"></EditText><br />
<br />
<Button android:layout_width="wrap_content"<br />
android:layout_height="wrap_content" android:id="@+id/saveContact_buttonEdit"<br />
android:text="@string/saveButton" android:gravity="center_horizontal"<br />
android:layout_gravity="center_horizontal" android:textSize="20dp"></Button><br />
</LinearLayout><br />
</source><br />
8.1.6. Now build your project so that the ids are generated in R.java<br />
<br />
===8.2 Create EditContactActivity===<br />
8.2.1 Create the EditContactActivity in your package and make sure it extends Activity class.<br />
<source lang="java"><br />
package cs.ecl.team1.android;<br />
<br />
import android.app.Activity;<br />
public class AddContactActivity extends Activity {<br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
}<br />
}<br />
</source><br />
<br />
8.2.2 Add private fields:<br />
<source lang="java"><br />
private String firstName;<br />
private String lastName;<br />
private String email;<br />
</source><br />
8.2.3 Make sure that on creation it adds the edit layout to the view, so change the OnCreate method:<br />
<source lang="java"><br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.edit); // adds edit layout to view<br />
}<br />
}<br />
</source><br />
8.2.4 get the Intent of this Activity (later when starting this activity, we will send an Intent including the data of the selected student for editing). Then read he data from it and set the EditTexts values:<br />
<source lang="java"><br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.edit); // adds edit layout to view<br />
<br />
Intent i = this.getIntent(); // get this page intent<br />
<br />
// read the data from the Intent<br />
EditText fNameEditText = (EditText) findViewById(R.id.firstNameEdit);<br />
fNameEditText.setText(i.getStringExtra("oldFirstName"));<br />
<br />
EditText lNameEditText = (EditText) findViewById(R.id.lastNameEdit);<br />
lNameEditText.setText(i.getStringExtra("oldLastName"));<br />
<br />
EditText emailEditText = (EditText) findViewById(R.id.emailEdit);<br />
emailEditText.setText(i.getStringExtra("oldEmail"));<br />
<br />
<br />
}<br />
}<br />
</source><br />
<br />
8.2.5 Add and implement the save button: in the OnCreate method:<br />
<br />
<source lang="java"><br />
//save Button implementation<br />
Button saveButton = (Button) findViewById(R.id.saveContact_buttonEdit);<br />
saveButton.setOnClickListener(new OnClickListener() {<br />
public void onClick(View arg0) {<br />
firstName = ((EditText) findViewById(R.id.firstNameEdit)).getText().toString();<br />
lastName = ((EditText) findViewById(R.id.lastNameEdit)).getText().toString();<br />
email = ((EditText) findViewById(R.id.emailEdit)).getText().toString();<br />
<br />
finish();<br />
}<br />
});<br />
</source><br />
<br />
8.3.5 Now you need to override the finish() method:<br />
<source lang="java"><br />
@Override<br />
public void finish() {<br />
Intent i = new Intent();<br />
if (firstName.equals("") && lastName.equals("") && email.equals("")) {<br />
setResult(0);<br />
}<br />
else { // add the modified data to the intent<br />
i.putExtra("newFirstName", firstName);<br />
i.putExtra("newLastName", lastName);<br />
i.putExtra("newEmail", email);<br />
setResult(RESULT_OK, i);<br />
}<br />
super.finish();<br />
}<br />
</source><br />
8.3.6 Here is the completed source of the EditContactActivity:<br />
<source lang="java"><br />
package cs.ecl.team1.android;<br />
<br />
import android.app.Activity;<br />
import android.content.Intent;<br />
import android.os.Bundle;<br />
import android.view.View;<br />
import android.view.View.OnClickListener;<br />
import android.widget.Button;<br />
import android.widget.EditText;<br />
<br />
<br />
public class EditContactActivity extends Activity {<br />
private String firstName;<br />
private String lastName;<br />
private String email;<br />
<br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
<br />
setContentView(R.layout.edit);<br />
<br />
// get the intent sent to this class<br />
Intent i = this.getIntent();<br />
<br />
EditText fNameEditText = (EditText) findViewById(R.id.firstNameEdit);<br />
fNameEditText.setText(i.getStringExtra("oldFirstName"));<br />
<br />
EditText lNameEditText = (EditText) findViewById(R.id.lastNameEdit);<br />
lNameEditText.setText(i.getStringExtra("oldLastName"));<br />
<br />
EditText emailEditText = (EditText) findViewById(R.id.emailEdit);<br />
emailEditText.setText(i.getStringExtra("oldEmail"));<br />
<br />
<br />
//save Button implementation<br />
Button saveButton = (Button) findViewById(R.id.saveContact_buttonEdit);<br />
saveButton.setOnClickListener(new OnClickListener() {<br />
public void onClick(View arg0) {<br />
firstName = ((EditText) findViewById(R.id.firstNameEdit)).getText().toString();<br />
lastName = ((EditText) findViewById(R.id.lastNameEdit)).getText().toString();<br />
email = ((EditText) findViewById(R.id.emailEdit)).getText().toString();<br />
<br />
finish();<br />
}<br />
});<br />
}<br />
<br />
@Override<br />
public void finish() {<br />
Intent i = new Intent();<br />
if (firstName.equals("") && lastName.equals("") && email.equals("")) {<br />
setResult(0);<br />
}<br />
else {<br />
i.putExtra("newFirstName", firstName);<br />
i.putExtra("newLastName", lastName);<br />
i.putExtra("newEmail", email);<br />
setResult(RESULT_OK, i);<br />
}<br />
super.finish();<br />
}<br />
<br />
<br />
}<br />
<br />
</source><br />
<br />
===8.3 Add the EditContactActivity to the Android Manifest===<br />
Now we have to declare our EditContactActivity in the Manifest:<br />
open the AndroidManifest.xml and add this:<br />
<source lang="java"><br />
<activity android:label="Edit Contact" android:name="EditContactActivity"></activity><br />
</source><br />
<br />
===8.4 Implement the EditContact in the main activity class===<br />
8.4.1 Add the following private fields to the ContactList Activity :<br />
<source lang=java><br />
// added for Edit<br />
private static final int EDIT_CONTACT =1;<br />
private Student selectedStudent;<br />
<br />
</source><br />
<br />
8.4.2 In the onOptionsItemSelected(MenuItem item) method add the following case to the switch code block:<br />
<br />
<source lang="java"><br />
case R.id.item4:// Edit<br />
// set the private field :selectedStudent so that it can be accessed later<br />
selectedStudent = (Student)contactsList.getSelectedItem();<br />
// create an Intent for EditContactActivity class<br />
Intent j = new Intent(this, EditContactActivity.class);<br />
// add the selected student's data to the intent so that the EditContactActivity class can read them<br />
j.putExtra("oldFirstName",selectedStudent.getFirstname());<br />
j.putExtra("oldLastName", selectedStudent.getLastName());<br />
j.putExtra("oldEmail",selectedStudent.getEmail());<br />
// Start the EditContactActivity activity<br />
startActivityForResult(j, EDIT_CONTACT);<br />
break;<br />
<br />
</source><br />
8.4.3 Modify the onActivityResult() method to accommodate the results of the EditContactActivity. Here is the completed code if this method:<br />
<source lang="java"><br />
@Override<br />
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {// modified to implement Edit<br />
switch (requestCode){<br />
case CREATE_CONTACT: // Add new Contact<br />
if (resultCode == Activity.RESULT_OK) {<br />
studentList.addElement(new Student(intent.getExtras().getString("firstName"),<br />
intent.getExtras().getString("lastName"), intent.getExtras().getString("email")));<br />
}<br />
else {<br />
showDialog("No contact was added!"); <br />
}<br />
displayData(studentList);<br />
break;<br />
case EDIT_CONTACT: // edit the selected Student<br />
// implement Edit<br />
if (resultCode == Activity.RESULT_OK) {<br />
Student oldS = selectedStudent;<br />
Student newS= new Student(intent.getExtras().getString("newFirstName"),<br />
intent.getExtras().getString("newLastName"),<br />
intent.getExtras().getString("newEmail"));<br />
for(int i = 0; i< studentList.size() ; i++){<br />
Student s= (Student)studentList.elementAt(i);<br />
if (s.getName().compareTo(oldS.getName())==0 && s.getEmail().compareTo(s.getEmail())==0){<br />
studentList.remove(s);<br />
studentList.add(newS);<br />
}<br />
<br />
}<br />
<br />
} else {<br />
showDialog("No contact was edited!");<br />
}<br />
displayData(studentList); <br />
<br />
break;<br />
default:<br />
break;<br />
}<br />
<br />
}<br />
<br />
</source><br />
<br />
===8.5 Edit Contact In action ===<br />
8.5.1 Build and run the project. Scrole mous buton to select a contact, and then click on the menu button of the virtual device. and then click on the EditContact menu option:<br />
[[Image: editMenuOption.png | 450px]]<br/><br />
8.5.2<br />
[[Image: editView.png | 450px]]<br/><br />
[[Image: editViewEdited.png | 450px]]<br/><br />
[[Image: editViewSaved.png | 450px]]<br/></div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/Android/Edit_Contact&diff=61891Teams Winter 2011/team1/Android/Edit Contact2011-04-07T16:57:15Z<p>Ladanzahir: /* 8.4 Implement the EditContact in the main activity class */</p>
<hr />
<div>== 8. Edit Contact ==<br />
===8.1 Create Edit Layout===<br />
8.1.1 Add the String value for the layout title to String.xml:===<br />
<source lang="java"><br />
<string name="editContact_textView">Edit Contact</string><br />
</source><br />
8.1.2 Right click on layout -> New -> Android XML File .<br/><br />
8.1.3 Enter edit.xml for the file name and check Layout:<br/><br />
8.1.4 Using Linear Layout, create this layout for editing contact information:<br/><br />
[[Image: editContactLayout.png | 250px]]<br/><br />
8.1.5 Here is the edit.xml implementation:<br />
<source lang="java"><br />
<?xml version="1.0" encoding="utf-8"?><br />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"<br />
android:layout_width="match_parent" android:layout_height="match_parent"<br />
android:orientation="vertical"><br />
<TextView android:layout_width="wrap_content"<br />
android:layout_height="wrap_content" android:id="@+id/titleTextViewEdit"<br />
android:gravity="center_vertical" android:textSize="30dp"<br />
android:layout_gravity="center" android:text="@string/editContact_textView"></TextView><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:layout_marginBottom="3dp" android:hint="@string/hint_first_name" android:id="@+id/firstNameEdit"></EditText><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:isScrollContainer="true"<br />
android:layout_marginBottom="3dp" android:hint="@string/hint_last_name" android:id="@+id/lastNameEdit"></EditText><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:layout_marginBottom="3dp" android:hint="@string/hint_email" android:id="@+id/emailEdit"></EditText><br />
<br />
<Button android:layout_width="wrap_content"<br />
android:layout_height="wrap_content" android:id="@+id/saveContact_buttonEdit"<br />
android:text="@string/saveButton" android:gravity="center_horizontal"<br />
android:layout_gravity="center_horizontal" android:textSize="20dp"></Button><br />
</LinearLayout><br />
</source><br />
8.1.6. Now build your project so that the ids are generated in R.java<br />
<br />
===8.2 Create EditContactActivity===<br />
8.2.1 Create the EditContactActivity in your package and make sure it extends Activity class.<br />
<source lang="java"><br />
package cs.ecl.team1.android;<br />
<br />
import android.app.Activity;<br />
public class AddContactActivity extends Activity {<br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
}<br />
}<br />
</source><br />
<br />
8.2.2 Add private fields:<br />
<source lang="java"><br />
private String firstName;<br />
private String lastName;<br />
private String email;<br />
</source><br />
8.2.3 Make sure that on creation it adds the edit layout to the view, so change the OnCreate method:<br />
<source lang="java"><br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.edit); // adds edit layout to view<br />
}<br />
}<br />
</source><br />
8.2.4 get the Intent of this Activity (later when starting this activity, we will send an Intent including the data of the selected student for editing). Then read he data from it and set the EditTexts values:<br />
<source lang="java"><br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.edit); // adds edit layout to view<br />
<br />
Intent i = this.getIntent(); // get this page intent<br />
<br />
// read the data from the Intent<br />
EditText fNameEditText = (EditText) findViewById(R.id.firstNameEdit);<br />
fNameEditText.setText(i.getStringExtra("oldFirstName"));<br />
<br />
EditText lNameEditText = (EditText) findViewById(R.id.lastNameEdit);<br />
lNameEditText.setText(i.getStringExtra("oldLastName"));<br />
<br />
EditText emailEditText = (EditText) findViewById(R.id.emailEdit);<br />
emailEditText.setText(i.getStringExtra("oldEmail"));<br />
<br />
<br />
}<br />
}<br />
</source><br />
<br />
8.2.5 Add and implement the save button: in the OnCreate method:<br />
<br />
<source lang="java"><br />
//save Button implementation<br />
Button saveButton = (Button) findViewById(R.id.saveContact_buttonEdit);<br />
saveButton.setOnClickListener(new OnClickListener() {<br />
public void onClick(View arg0) {<br />
firstName = ((EditText) findViewById(R.id.firstNameEdit)).getText().toString();<br />
lastName = ((EditText) findViewById(R.id.lastNameEdit)).getText().toString();<br />
email = ((EditText) findViewById(R.id.emailEdit)).getText().toString();<br />
<br />
finish();<br />
}<br />
});<br />
</source><br />
<br />
8.3.5 Now you need to override the finish() method:<br />
<source lang="java"><br />
@Override<br />
public void finish() {<br />
Intent i = new Intent();<br />
if (firstName.equals("") && lastName.equals("") && email.equals("")) {<br />
setResult(0);<br />
}<br />
else { // add the modified data to the intent<br />
i.putExtra("newFirstName", firstName);<br />
i.putExtra("newLastName", lastName);<br />
i.putExtra("newEmail", email);<br />
setResult(RESULT_OK, i);<br />
}<br />
super.finish();<br />
}<br />
</source><br />
8.3.6 Here is the completed source of the EditContactActivity:<br />
<source lang="java"><br />
package cs.ecl.team1.android;<br />
<br />
import android.app.Activity;<br />
import android.content.Intent;<br />
import android.os.Bundle;<br />
import android.view.View;<br />
import android.view.View.OnClickListener;<br />
import android.widget.Button;<br />
import android.widget.EditText;<br />
<br />
<br />
public class EditContactActivity extends Activity {<br />
private String firstName;<br />
private String lastName;<br />
private String email;<br />
<br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
<br />
setContentView(R.layout.edit);<br />
<br />
// get the intent sent to this class<br />
Intent i = this.getIntent();<br />
<br />
EditText fNameEditText = (EditText) findViewById(R.id.firstNameEdit);<br />
fNameEditText.setText(i.getStringExtra("oldFirstName"));<br />
<br />
EditText lNameEditText = (EditText) findViewById(R.id.lastNameEdit);<br />
lNameEditText.setText(i.getStringExtra("oldLastName"));<br />
<br />
EditText emailEditText = (EditText) findViewById(R.id.emailEdit);<br />
emailEditText.setText(i.getStringExtra("oldEmail"));<br />
<br />
<br />
//save Button implementation<br />
Button saveButton = (Button) findViewById(R.id.saveContact_buttonEdit);<br />
saveButton.setOnClickListener(new OnClickListener() {<br />
public void onClick(View arg0) {<br />
firstName = ((EditText) findViewById(R.id.firstNameEdit)).getText().toString();<br />
lastName = ((EditText) findViewById(R.id.lastNameEdit)).getText().toString();<br />
email = ((EditText) findViewById(R.id.emailEdit)).getText().toString();<br />
<br />
finish();<br />
}<br />
});<br />
}<br />
<br />
@Override<br />
public void finish() {<br />
Intent i = new Intent();<br />
if (firstName.equals("") && lastName.equals("") && email.equals("")) {<br />
setResult(0);<br />
}<br />
else {<br />
i.putExtra("newFirstName", firstName);<br />
i.putExtra("newLastName", lastName);<br />
i.putExtra("newEmail", email);<br />
setResult(RESULT_OK, i);<br />
}<br />
super.finish();<br />
}<br />
<br />
<br />
}<br />
<br />
</source><br />
<br />
===8.3 Add the EditContactActivity to the Android Manifest===<br />
Now we have to declare our EditContactActivity in the Manifest:<br />
open the AndroidManifest.xml and add this:<br />
<source lang="java"><br />
<activity android:label="Edit Contact" android:name="EditContactActivity"></activity><br />
</source><br />
<br />
===8.4 Implement the EditContact in the main activity class===<br />
8.4.1 Add the following private fields to the ContactList Activity :<br />
<source lang=java><br />
// added for Edit<br />
private static final int EDIT_CONTACT =1;<br />
private Student selectedStudent;<br />
<br />
</source><br />
<br />
8.4.2 In the onOptionsItemSelected(MenuItem item) method add the following case to the switch code block:<br />
<br />
<source lang="java"><br />
case R.id.item4:// Edit<br />
// set the private field :selectedStudent so that it can be accessed later<br />
selectedStudent = (Student)contactsList.getSelectedItem();<br />
// create an Intent for EditContactActivity class<br />
Intent j = new Intent(this, EditContactActivity.class);<br />
// add the selected student's data to the intent so that the EditContactActivity class can read them<br />
j.putExtra("oldFirstName",selectedStudent.getFirstname());<br />
j.putExtra("oldLastName", selectedStudent.getLastName());<br />
j.putExtra("oldEmail",selectedStudent.getEmail());<br />
// Start the EditContactActivity activity<br />
startActivityForResult(j, EDIT_CONTACT);<br />
break;<br />
<br />
</source><br />
8.4.3 Modify the onActivityResult() method to accommodate the results of the EditContactActivity. Here is the completed code if this method:<br />
<source lang="java"><br />
@Override<br />
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {// modified to implement Edit<br />
switch (requestCode){<br />
case CREATE_CONTACT: // Add new Contact<br />
if (resultCode == Activity.RESULT_OK) {<br />
studentList.addElement(new Student(intent.getExtras().getString("firstName"),<br />
intent.getExtras().getString("lastName"), intent.getExtras().getString("email")));<br />
}<br />
else {<br />
showDialog("No contact was added!"); <br />
}<br />
displayData(studentList);<br />
break;<br />
case EDIT_CONTACT: // edit the selected Student<br />
// implement Edit<br />
if (resultCode == Activity.RESULT_OK) {<br />
Student oldS = selectedStudent;<br />
Student newS= new Student(intent.getExtras().getString("newFirstName"),<br />
intent.getExtras().getString("newLastName"),<br />
intent.getExtras().getString("newEmail"));<br />
for(int i = 0; i< studentList.size() ; i++){<br />
Student s= (Student)studentList.elementAt(i);<br />
if (s.getName().compareTo(oldS.getName())==0 && s.getEmail().compareTo(s.getEmail())==0){<br />
studentList.remove(s);<br />
studentList.add(newS);<br />
}<br />
<br />
}<br />
<br />
} else {<br />
showDialog("No contact was edited!");<br />
}<br />
displayData(studentList); <br />
<br />
break;<br />
default:<br />
break;<br />
}<br />
<br />
}<br />
<br />
</source><br />
<br />
===8.5 Edit Contact In action ===<br />
[[Image: editMenuOption.png | 450px]]<br/><br />
[[Image: editView.png | 450px]]<br/><br />
[[Image: editViewEdited.png | 450px]]<br/><br />
[[Image: editViewSaved.png | 450px]]<br/></div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/Android/Edit_Contact&diff=61890Teams Winter 2011/team1/Android/Edit Contact2011-04-07T16:56:35Z<p>Ladanzahir: /* 8.4 Implement The EditContact in the main activity class */</p>
<hr />
<div>== 8. Edit Contact ==<br />
===8.1 Create Edit Layout===<br />
8.1.1 Add the String value for the layout title to String.xml:===<br />
<source lang="java"><br />
<string name="editContact_textView">Edit Contact</string><br />
</source><br />
8.1.2 Right click on layout -> New -> Android XML File .<br/><br />
8.1.3 Enter edit.xml for the file name and check Layout:<br/><br />
8.1.4 Using Linear Layout, create this layout for editing contact information:<br/><br />
[[Image: editContactLayout.png | 250px]]<br/><br />
8.1.5 Here is the edit.xml implementation:<br />
<source lang="java"><br />
<?xml version="1.0" encoding="utf-8"?><br />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"<br />
android:layout_width="match_parent" android:layout_height="match_parent"<br />
android:orientation="vertical"><br />
<TextView android:layout_width="wrap_content"<br />
android:layout_height="wrap_content" android:id="@+id/titleTextViewEdit"<br />
android:gravity="center_vertical" android:textSize="30dp"<br />
android:layout_gravity="center" android:text="@string/editContact_textView"></TextView><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:layout_marginBottom="3dp" android:hint="@string/hint_first_name" android:id="@+id/firstNameEdit"></EditText><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:isScrollContainer="true"<br />
android:layout_marginBottom="3dp" android:hint="@string/hint_last_name" android:id="@+id/lastNameEdit"></EditText><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:layout_marginBottom="3dp" android:hint="@string/hint_email" android:id="@+id/emailEdit"></EditText><br />
<br />
<Button android:layout_width="wrap_content"<br />
android:layout_height="wrap_content" android:id="@+id/saveContact_buttonEdit"<br />
android:text="@string/saveButton" android:gravity="center_horizontal"<br />
android:layout_gravity="center_horizontal" android:textSize="20dp"></Button><br />
</LinearLayout><br />
</source><br />
8.1.6. Now build your project so that the ids are generated in R.java<br />
<br />
===8.2 Create EditContactActivity===<br />
8.2.1 Create the EditContactActivity in your package and make sure it extends Activity class.<br />
<source lang="java"><br />
package cs.ecl.team1.android;<br />
<br />
import android.app.Activity;<br />
public class AddContactActivity extends Activity {<br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
}<br />
}<br />
</source><br />
<br />
8.2.2 Add private fields:<br />
<source lang="java"><br />
private String firstName;<br />
private String lastName;<br />
private String email;<br />
</source><br />
8.2.3 Make sure that on creation it adds the edit layout to the view, so change the OnCreate method:<br />
<source lang="java"><br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.edit); // adds edit layout to view<br />
}<br />
}<br />
</source><br />
8.2.4 get the Intent of this Activity (later when starting this activity, we will send an Intent including the data of the selected student for editing). Then read he data from it and set the EditTexts values:<br />
<source lang="java"><br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.edit); // adds edit layout to view<br />
<br />
Intent i = this.getIntent(); // get this page intent<br />
<br />
// read the data from the Intent<br />
EditText fNameEditText = (EditText) findViewById(R.id.firstNameEdit);<br />
fNameEditText.setText(i.getStringExtra("oldFirstName"));<br />
<br />
EditText lNameEditText = (EditText) findViewById(R.id.lastNameEdit);<br />
lNameEditText.setText(i.getStringExtra("oldLastName"));<br />
<br />
EditText emailEditText = (EditText) findViewById(R.id.emailEdit);<br />
emailEditText.setText(i.getStringExtra("oldEmail"));<br />
<br />
<br />
}<br />
}<br />
</source><br />
<br />
8.2.5 Add and implement the save button: in the OnCreate method:<br />
<br />
<source lang="java"><br />
//save Button implementation<br />
Button saveButton = (Button) findViewById(R.id.saveContact_buttonEdit);<br />
saveButton.setOnClickListener(new OnClickListener() {<br />
public void onClick(View arg0) {<br />
firstName = ((EditText) findViewById(R.id.firstNameEdit)).getText().toString();<br />
lastName = ((EditText) findViewById(R.id.lastNameEdit)).getText().toString();<br />
email = ((EditText) findViewById(R.id.emailEdit)).getText().toString();<br />
<br />
finish();<br />
}<br />
});<br />
</source><br />
<br />
8.3.5 Now you need to override the finish() method:<br />
<source lang="java"><br />
@Override<br />
public void finish() {<br />
Intent i = new Intent();<br />
if (firstName.equals("") && lastName.equals("") && email.equals("")) {<br />
setResult(0);<br />
}<br />
else { // add the modified data to the intent<br />
i.putExtra("newFirstName", firstName);<br />
i.putExtra("newLastName", lastName);<br />
i.putExtra("newEmail", email);<br />
setResult(RESULT_OK, i);<br />
}<br />
super.finish();<br />
}<br />
</source><br />
8.3.6 Here is the completed source of the EditContactActivity:<br />
<source lang="java"><br />
package cs.ecl.team1.android;<br />
<br />
import android.app.Activity;<br />
import android.content.Intent;<br />
import android.os.Bundle;<br />
import android.view.View;<br />
import android.view.View.OnClickListener;<br />
import android.widget.Button;<br />
import android.widget.EditText;<br />
<br />
<br />
public class EditContactActivity extends Activity {<br />
private String firstName;<br />
private String lastName;<br />
private String email;<br />
<br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
<br />
setContentView(R.layout.edit);<br />
<br />
// get the intent sent to this class<br />
Intent i = this.getIntent();<br />
<br />
EditText fNameEditText = (EditText) findViewById(R.id.firstNameEdit);<br />
fNameEditText.setText(i.getStringExtra("oldFirstName"));<br />
<br />
EditText lNameEditText = (EditText) findViewById(R.id.lastNameEdit);<br />
lNameEditText.setText(i.getStringExtra("oldLastName"));<br />
<br />
EditText emailEditText = (EditText) findViewById(R.id.emailEdit);<br />
emailEditText.setText(i.getStringExtra("oldEmail"));<br />
<br />
<br />
//save Button implementation<br />
Button saveButton = (Button) findViewById(R.id.saveContact_buttonEdit);<br />
saveButton.setOnClickListener(new OnClickListener() {<br />
public void onClick(View arg0) {<br />
firstName = ((EditText) findViewById(R.id.firstNameEdit)).getText().toString();<br />
lastName = ((EditText) findViewById(R.id.lastNameEdit)).getText().toString();<br />
email = ((EditText) findViewById(R.id.emailEdit)).getText().toString();<br />
<br />
finish();<br />
}<br />
});<br />
}<br />
<br />
@Override<br />
public void finish() {<br />
Intent i = new Intent();<br />
if (firstName.equals("") && lastName.equals("") && email.equals("")) {<br />
setResult(0);<br />
}<br />
else {<br />
i.putExtra("newFirstName", firstName);<br />
i.putExtra("newLastName", lastName);<br />
i.putExtra("newEmail", email);<br />
setResult(RESULT_OK, i);<br />
}<br />
super.finish();<br />
}<br />
<br />
<br />
}<br />
<br />
</source><br />
<br />
===8.3 Add the EditContactActivity to the Android Manifest===<br />
Now we have to declare our EditContactActivity in the Manifest:<br />
open the AndroidManifest.xml and add this:<br />
<source lang="java"><br />
<activity android:label="Edit Contact" android:name="EditContactActivity"></activity><br />
</source><br />
<br />
===8.4 Implement the EditContact in the main activity class===<br />
8.4.1 Add the following private fields to the ContactList Activity :<br />
<source lang=java><br />
// added for Edit<br />
private static final int EDIT_CONTACT =1;<br />
private Student selectedStudent;<br />
<br />
</source><br />
<br />
8.4.2 In the onOptionsItemSelected(MenuItem item) method add the following case to the switch code block:<br />
<br />
<source lang="java"><br />
case R.id.item4:// Edit<br />
// set the private field :selectedStudent so that it can be accessed later<br />
selectedStudent = (Student)contactsList.getSelectedItem();<br />
// create an Intent for EditContactActivity class<br />
Intent j = new Intent(this, EditContactActivity.class);<br />
// add the selected student's data to the intent so that the EditContactActivity class can read them<br />
j.putExtra("oldFirstName",selectedStudent.getFirstname());<br />
j.putExtra("oldLastName", selectedStudent.getLastName());<br />
j.putExtra("oldEmail",selectedStudent.getEmail());<br />
// Start the EditContactActivity activity<br />
startActivityForResult(j, EDIT_CONTACT);<br />
break;<br />
<br />
</source><br />
8.4.3 Modify the onActivityResult() method to accommodate the results of the EditContactActivity. Here is the completed code if this method:<br />
<source lang="java"><br />
@Override<br />
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {// modified to implement Edit<br />
switch (requestCode){<br />
case CREATE_CONTACT:<br />
if (resultCode == Activity.RESULT_OK) {<br />
studentList.addElement(new Student(intent.getExtras().getString("firstName"),<br />
intent.getExtras().getString("lastName"), intent.getExtras().getString("email")));<br />
}<br />
else {<br />
showDialog("No contact was added!"); <br />
}<br />
displayData(studentList);<br />
break;<br />
case EDIT_CONTACT: // edit the selected Student<br />
// implement Edit<br />
if (resultCode == Activity.RESULT_OK) {<br />
Student oldS = selectedStudent;<br />
Student newS= new Student(intent.getExtras().getString("newFirstName"),<br />
intent.getExtras().getString("newLastName"),<br />
intent.getExtras().getString("newEmail"));<br />
for(int i = 0; i< studentList.size() ; i++){<br />
Student s= (Student)studentList.elementAt(i);<br />
if (s.getName().compareTo(oldS.getName())==0 && s.getEmail().compareTo(s.getEmail())==0){<br />
studentList.remove(s);<br />
studentList.add(newS);<br />
}<br />
<br />
}<br />
<br />
} else {<br />
showDialog("No contact was edited!");<br />
}<br />
displayData(studentList); <br />
<br />
break;<br />
default:<br />
break;<br />
}<br />
<br />
}<br />
<br />
</source><br />
<br />
===8.5 Edit Contact In action ===<br />
[[Image: editMenuOption.png | 450px]]<br/><br />
[[Image: editView.png | 450px]]<br/><br />
[[Image: editViewEdited.png | 450px]]<br/><br />
[[Image: editViewSaved.png | 450px]]<br/></div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/Android/Edit_Contact&diff=61887Teams Winter 2011/team1/Android/Edit Contact2011-04-07T16:46:39Z<p>Ladanzahir: /* 8.4 Implement The EditContact in the main activity class */</p>
<hr />
<div>== 8. Edit Contact ==<br />
===8.1 Create Edit Layout===<br />
8.1.1 Add the String value for the layout title to String.xml:===<br />
<source lang="java"><br />
<string name="editContact_textView">Edit Contact</string><br />
</source><br />
8.1.2 Right click on layout -> New -> Android XML File .<br/><br />
8.1.3 Enter edit.xml for the file name and check Layout:<br/><br />
8.1.4 Using Linear Layout, create this layout for editing contact information:<br/><br />
[[Image: editContactLayout.png | 250px]]<br/><br />
8.1.5 Here is the edit.xml implementation:<br />
<source lang="java"><br />
<?xml version="1.0" encoding="utf-8"?><br />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"<br />
android:layout_width="match_parent" android:layout_height="match_parent"<br />
android:orientation="vertical"><br />
<TextView android:layout_width="wrap_content"<br />
android:layout_height="wrap_content" android:id="@+id/titleTextViewEdit"<br />
android:gravity="center_vertical" android:textSize="30dp"<br />
android:layout_gravity="center" android:text="@string/editContact_textView"></TextView><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:layout_marginBottom="3dp" android:hint="@string/hint_first_name" android:id="@+id/firstNameEdit"></EditText><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:isScrollContainer="true"<br />
android:layout_marginBottom="3dp" android:hint="@string/hint_last_name" android:id="@+id/lastNameEdit"></EditText><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:layout_marginBottom="3dp" android:hint="@string/hint_email" android:id="@+id/emailEdit"></EditText><br />
<br />
<Button android:layout_width="wrap_content"<br />
android:layout_height="wrap_content" android:id="@+id/saveContact_buttonEdit"<br />
android:text="@string/saveButton" android:gravity="center_horizontal"<br />
android:layout_gravity="center_horizontal" android:textSize="20dp"></Button><br />
</LinearLayout><br />
</source><br />
8.1.6. Now build your project so that the ids are generated in R.java<br />
<br />
===8.2 Create EditContactActivity===<br />
8.2.1 Create the EditContactActivity in your package and make sure it extends Activity class.<br />
<source lang="java"><br />
package cs.ecl.team1.android;<br />
<br />
import android.app.Activity;<br />
public class AddContactActivity extends Activity {<br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
}<br />
}<br />
</source><br />
<br />
8.2.2 Add private fields:<br />
<source lang="java"><br />
private String firstName;<br />
private String lastName;<br />
private String email;<br />
</source><br />
8.2.3 Make sure that on creation it adds the edit layout to the view, so change the OnCreate method:<br />
<source lang="java"><br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.edit); // adds edit layout to view<br />
}<br />
}<br />
</source><br />
8.2.4 get the Intent of this Activity (later when starting this activity, we will send an Intent including the data of the selected student for editing). Then read he data from it and set the EditTexts values:<br />
<source lang="java"><br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.edit); // adds edit layout to view<br />
<br />
Intent i = this.getIntent(); // get this page intent<br />
<br />
// read the data from the Intent<br />
EditText fNameEditText = (EditText) findViewById(R.id.firstNameEdit);<br />
fNameEditText.setText(i.getStringExtra("oldFirstName"));<br />
<br />
EditText lNameEditText = (EditText) findViewById(R.id.lastNameEdit);<br />
lNameEditText.setText(i.getStringExtra("oldLastName"));<br />
<br />
EditText emailEditText = (EditText) findViewById(R.id.emailEdit);<br />
emailEditText.setText(i.getStringExtra("oldEmail"));<br />
<br />
<br />
}<br />
}<br />
</source><br />
<br />
8.2.5 Add and implement the save button: in the OnCreate method:<br />
<br />
<source lang="java"><br />
//save Button implementation<br />
Button saveButton = (Button) findViewById(R.id.saveContact_buttonEdit);<br />
saveButton.setOnClickListener(new OnClickListener() {<br />
public void onClick(View arg0) {<br />
firstName = ((EditText) findViewById(R.id.firstNameEdit)).getText().toString();<br />
lastName = ((EditText) findViewById(R.id.lastNameEdit)).getText().toString();<br />
email = ((EditText) findViewById(R.id.emailEdit)).getText().toString();<br />
<br />
finish();<br />
}<br />
});<br />
</source><br />
<br />
8.3.5 Now you need to override the finish() method:<br />
<source lang="java"><br />
@Override<br />
public void finish() {<br />
Intent i = new Intent();<br />
if (firstName.equals("") && lastName.equals("") && email.equals("")) {<br />
setResult(0);<br />
}<br />
else { // add the modified data to the intent<br />
i.putExtra("newFirstName", firstName);<br />
i.putExtra("newLastName", lastName);<br />
i.putExtra("newEmail", email);<br />
setResult(RESULT_OK, i);<br />
}<br />
super.finish();<br />
}<br />
</source><br />
8.3.6 Here is the completed source of the EditContactActivity:<br />
<source lang="java"><br />
package cs.ecl.team1.android;<br />
<br />
import android.app.Activity;<br />
import android.content.Intent;<br />
import android.os.Bundle;<br />
import android.view.View;<br />
import android.view.View.OnClickListener;<br />
import android.widget.Button;<br />
import android.widget.EditText;<br />
<br />
<br />
public class EditContactActivity extends Activity {<br />
private String firstName;<br />
private String lastName;<br />
private String email;<br />
<br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
<br />
setContentView(R.layout.edit);<br />
<br />
// get the intent sent to this class<br />
Intent i = this.getIntent();<br />
<br />
EditText fNameEditText = (EditText) findViewById(R.id.firstNameEdit);<br />
fNameEditText.setText(i.getStringExtra("oldFirstName"));<br />
<br />
EditText lNameEditText = (EditText) findViewById(R.id.lastNameEdit);<br />
lNameEditText.setText(i.getStringExtra("oldLastName"));<br />
<br />
EditText emailEditText = (EditText) findViewById(R.id.emailEdit);<br />
emailEditText.setText(i.getStringExtra("oldEmail"));<br />
<br />
<br />
//save Button implementation<br />
Button saveButton = (Button) findViewById(R.id.saveContact_buttonEdit);<br />
saveButton.setOnClickListener(new OnClickListener() {<br />
public void onClick(View arg0) {<br />
firstName = ((EditText) findViewById(R.id.firstNameEdit)).getText().toString();<br />
lastName = ((EditText) findViewById(R.id.lastNameEdit)).getText().toString();<br />
email = ((EditText) findViewById(R.id.emailEdit)).getText().toString();<br />
<br />
finish();<br />
}<br />
});<br />
}<br />
<br />
@Override<br />
public void finish() {<br />
Intent i = new Intent();<br />
if (firstName.equals("") && lastName.equals("") && email.equals("")) {<br />
setResult(0);<br />
}<br />
else {<br />
i.putExtra("newFirstName", firstName);<br />
i.putExtra("newLastName", lastName);<br />
i.putExtra("newEmail", email);<br />
setResult(RESULT_OK, i);<br />
}<br />
super.finish();<br />
}<br />
<br />
<br />
}<br />
<br />
</source><br />
<br />
===8.3 Add the EditContactActivity to the Android Manifest===<br />
Now we have to declare our EditContactActivity in the Manifest:<br />
open the AndroidManifest.xml and add this:<br />
<source lang="java"><br />
<activity android:label="Edit Contact" android:name="EditContactActivity"></activity><br />
</source><br />
<br />
===8.4 Implement The EditContact in the main activity class===<br />
8.4.1 Add the following private fields to the ContactList Activity :<br />
<source lang=java><br />
// added for Edit<br />
private static final int EDIT_CONTACT =1;<br />
private Student selectedStudent;<br />
<br />
</source><br />
<br />
8.4.2 In the onOptionsItemSelected(MenuItem item) method add the following case to the switch code block:<br />
<br />
<source lang="java"><br />
<br />
case R.id.item4:// Edit<br />
// set the private field :selectedStudent so that it can be accessed later<br />
selectedStudent = (Student)contactsList.getSelectedItem();<br />
// create an Intent<br />
Intent j = new Intent(this, EditContactActivity.class);<br />
// add the selected student's data to the intent so that the EditContactActivity class can read them<br />
j.putExtra("oldFirstName",selectedStudent.getFirstname());<br />
j.putExtra("oldLastName", selectedStudent.getLastName());<br />
j.putExtra("oldEmail",selectedStudent.getEmail());<br />
// Start the EditContactActivity activity<br />
startActivityForResult(j, EDIT_CONTACT);<br />
break;<br />
<br />
</source><br />
<br />
===8.5 Edit Contact In action ===<br />
[[Image: editMenuOption.png | 450px]]<br/><br />
[[Image: editView.png | 450px]]<br/><br />
[[Image: editViewEdited.png | 450px]]<br/><br />
[[Image: editViewSaved.png | 450px]]<br/></div>Ladanzahirhttps://wiki.cdot.senecacollege.ca/w/index.php?title=Teams_Winter_2011/team1/Android/Edit_Contact&diff=61886Teams Winter 2011/team1/Android/Edit Contact2011-04-07T16:40:29Z<p>Ladanzahir: /* 8.4 Implement The EditContact in the main activity class */</p>
<hr />
<div>== 8. Edit Contact ==<br />
===8.1 Create Edit Layout===<br />
8.1.1 Add the String value for the layout title to String.xml:===<br />
<source lang="java"><br />
<string name="editContact_textView">Edit Contact</string><br />
</source><br />
8.1.2 Right click on layout -> New -> Android XML File .<br/><br />
8.1.3 Enter edit.xml for the file name and check Layout:<br/><br />
8.1.4 Using Linear Layout, create this layout for editing contact information:<br/><br />
[[Image: editContactLayout.png | 250px]]<br/><br />
8.1.5 Here is the edit.xml implementation:<br />
<source lang="java"><br />
<?xml version="1.0" encoding="utf-8"?><br />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"<br />
android:layout_width="match_parent" android:layout_height="match_parent"<br />
android:orientation="vertical"><br />
<TextView android:layout_width="wrap_content"<br />
android:layout_height="wrap_content" android:id="@+id/titleTextViewEdit"<br />
android:gravity="center_vertical" android:textSize="30dp"<br />
android:layout_gravity="center" android:text="@string/editContact_textView"></TextView><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:layout_marginBottom="3dp" android:hint="@string/hint_first_name" android:id="@+id/firstNameEdit"></EditText><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:isScrollContainer="true"<br />
android:layout_marginBottom="3dp" android:hint="@string/hint_last_name" android:id="@+id/lastNameEdit"></EditText><br />
<br />
<EditText android:layout_width="match_parent"<br />
android:layout_height="wrap_content" android:layout_marginBottom="3dp" android:hint="@string/hint_email" android:id="@+id/emailEdit"></EditText><br />
<br />
<Button android:layout_width="wrap_content"<br />
android:layout_height="wrap_content" android:id="@+id/saveContact_buttonEdit"<br />
android:text="@string/saveButton" android:gravity="center_horizontal"<br />
android:layout_gravity="center_horizontal" android:textSize="20dp"></Button><br />
</LinearLayout><br />
</source><br />
8.1.6. Now build your project so that the ids are generated in R.java<br />
<br />
===8.2 Create EditContactActivity===<br />
8.2.1 Create the EditContactActivity in your package and make sure it extends Activity class.<br />
<source lang="java"><br />
package cs.ecl.team1.android;<br />
<br />
import android.app.Activity;<br />
public class AddContactActivity extends Activity {<br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
}<br />
}<br />
</source><br />
<br />
8.2.2 Add private fields:<br />
<source lang="java"><br />
private String firstName;<br />
private String lastName;<br />
private String email;<br />
</source><br />
8.2.3 Make sure that on creation it adds the edit layout to the view, so change the OnCreate method:<br />
<source lang="java"><br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.edit); // adds edit layout to view<br />
}<br />
}<br />
</source><br />
8.2.4 get the Intent of this Activity (later when starting this activity, we will send an Intent including the data of the selected student for editing). Then read he data from it and set the EditTexts values:<br />
<source lang="java"><br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.edit); // adds edit layout to view<br />
<br />
Intent i = this.getIntent(); // get this page intent<br />
<br />
// read the data from the Intent<br />
EditText fNameEditText = (EditText) findViewById(R.id.firstNameEdit);<br />
fNameEditText.setText(i.getStringExtra("oldFirstName"));<br />
<br />
EditText lNameEditText = (EditText) findViewById(R.id.lastNameEdit);<br />
lNameEditText.setText(i.getStringExtra("oldLastName"));<br />
<br />
EditText emailEditText = (EditText) findViewById(R.id.emailEdit);<br />
emailEditText.setText(i.getStringExtra("oldEmail"));<br />
<br />
<br />
}<br />
}<br />
</source><br />
<br />
8.2.5 Add and implement the save button: in the OnCreate method:<br />
<br />
<source lang="java"><br />
//save Button implementation<br />
Button saveButton = (Button) findViewById(R.id.saveContact_buttonEdit);<br />
saveButton.setOnClickListener(new OnClickListener() {<br />
public void onClick(View arg0) {<br />
firstName = ((EditText) findViewById(R.id.firstNameEdit)).getText().toString();<br />
lastName = ((EditText) findViewById(R.id.lastNameEdit)).getText().toString();<br />
email = ((EditText) findViewById(R.id.emailEdit)).getText().toString();<br />
<br />
finish();<br />
}<br />
});<br />
</source><br />
<br />
8.3.5 Now you need to override the finish() method:<br />
<source lang="java"><br />
@Override<br />
public void finish() {<br />
Intent i = new Intent();<br />
if (firstName.equals("") && lastName.equals("") && email.equals("")) {<br />
setResult(0);<br />
}<br />
else { // add the modified data to the intent<br />
i.putExtra("newFirstName", firstName);<br />
i.putExtra("newLastName", lastName);<br />
i.putExtra("newEmail", email);<br />
setResult(RESULT_OK, i);<br />
}<br />
super.finish();<br />
}<br />
</source><br />
8.3.6 Here is the completed source of the EditContactActivity:<br />
<source lang="java"><br />
package cs.ecl.team1.android;<br />
<br />
import android.app.Activity;<br />
import android.content.Intent;<br />
import android.os.Bundle;<br />
import android.view.View;<br />
import android.view.View.OnClickListener;<br />
import android.widget.Button;<br />
import android.widget.EditText;<br />
<br />
<br />
public class EditContactActivity extends Activity {<br />
private String firstName;<br />
private String lastName;<br />
private String email;<br />
<br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
<br />
setContentView(R.layout.edit);<br />
<br />
// get the intent sent to this class<br />
Intent i = this.getIntent();<br />
<br />
EditText fNameEditText = (EditText) findViewById(R.id.firstNameEdit);<br />
fNameEditText.setText(i.getStringExtra("oldFirstName"));<br />
<br />
EditText lNameEditText = (EditText) findViewById(R.id.lastNameEdit);<br />
lNameEditText.setText(i.getStringExtra("oldLastName"));<br />
<br />
EditText emailEditText = (EditText) findViewById(R.id.emailEdit);<br />
emailEditText.setText(i.getStringExtra("oldEmail"));<br />
<br />
<br />
//save Button implementation<br />
Button saveButton = (Button) findViewById(R.id.saveContact_buttonEdit);<br />
saveButton.setOnClickListener(new OnClickListener() {<br />
public void onClick(View arg0) {<br />
firstName = ((EditText) findViewById(R.id.firstNameEdit)).getText().toString();<br />
lastName = ((EditText) findViewById(R.id.lastNameEdit)).getText().toString();<br />
email = ((EditText) findViewById(R.id.emailEdit)).getText().toString();<br />
<br />
finish();<br />
}<br />
});<br />
}<br />
<br />
@Override<br />
public void finish() {<br />
Intent i = new Intent();<br />
if (firstName.equals("") && lastName.equals("") && email.equals("")) {<br />
setResult(0);<br />
}<br />
else {<br />
i.putExtra("newFirstName", firstName);<br />
i.putExtra("newLastName", lastName);<br />
i.putExtra("newEmail", email);<br />
setResult(RESULT_OK, i);<br />
}<br />
super.finish();<br />
}<br />
<br />
<br />
}<br />
<br />
</source><br />
<br />
===8.3 Add the EditContactActivity to the Android Manifest===<br />
Now we have to declare our EditContactActivity in the Manifest:<br />
open the AndroidManifest.xml and add this:<br />
<source lang="java"><br />
<activity android:label="Edit Contact" android:name="EditContactActivity"></activity><br />
</source><br />
<br />
===8.4 Implement The EditContact in the main activity class===<br />
8.4.1 Add the following private fields to the ContactList Activity :<br />
<source lang=java><br />
// added for Edit<br />
private static final int EDIT_CONTACT =1;<br />
private Student selectedStudent;<br />
<br />
</source><br />
<br />
===8.5 Edit Contact In action ===<br />
[[Image: editMenuOption.png | 450px]]<br/><br />
[[Image: editView.png | 450px]]<br/><br />
[[Image: editViewEdited.png | 450px]]<br/><br />
[[Image: editViewSaved.png | 450px]]<br/></div>Ladanzahir