Tutorial: Building an Android Application in 6 Steps

A few months ago, when I started working with Android, I built an Employee Directory application as an experimentation project. I thought this application could be useful to other developers starting with Android, so I’ve made it available as a Google Code project. The Employee Directory application is built in six easy steps, each building on top of each other. The end result is a simple, yet functional application that allows you to:

  • Look up employees by name in a local SQLite database
  • Look at the details of an employee
  • Call, email, text an employee from within the application
  • Navigate up and down the organization’s org chart

You can download the Eclipse projects here. androidtutorial-1.0.zip includes a project for each step. EmployeeDirectory6 is the final application. If you prefer, you can also browse the source code here.

Setting Up and Running the Projects in Eclipse

Here are some quick steps to set up and run the projects in Eclipse. If you just want to see how the application is built without setting up the projects, go straight to Step 1 below.

  1. Download androidtutorial-1.0.zip here (or check out the project from the trunk).
  2. Follow the steps described here to install the Android SDK and the ADT plugin for Eclipse.
  3. In Eclipse, create a new Workspace and set its default Java Compiler compliance level to 1.5.
  4. Import the projects: File > Import > General > Existing Projects into Workspace, and point to the androidtutorial directory.
  5. Click here for instructions on how to run your projects using the Android emulator or on your device.

Step 1: Basic Layout

In this first step, we define the user interface for searching employees.

Code highlights:

EmployeeList.java: The default Activity of the application. setContentView() is used to set the layout to main.xml.

main.xml: the layout for the default activity of the application.

Step 2: Working with Lists

In this second step, we add a ListView component that will be used (in the following step) to display the list of employees matching the search criteria. In this step, we just use an ArrayAdapter to display sample data in the list.

Code highlights:

main.xml: The updated layout with the ListView.

EmployeeList.java: An ArrayAdapter is used to populate the ListView.

Step 3: Working with a SQLite Database

In this third step, we use a SQLite database to persist the employees. When the user clicks the Search button, we query the database, and populate the list with the employees matching the search criteria.

Code highlights:

EmployeeList.java:

  • In onCreate(), we use the DatabaseHelper class to open the database.
  • In search(), we use a Cursor to query the database. We then use a SimpleCursorAdapter to bind the ListView to the Cursor using a custom layout (employee_list_item) to display each item in the list.

DatabaseHelper.java: We extend SQLiteOpenHelper to manage the access to our database: If the database doesn’t yet exist, we create the employee table and populate it with sample data.

employee_list_item.xml: Layout to display each item in the list.

Step 4: Using Intents and passing information between Activities

In this fourth step, we create an Activity to display the details of the employee selected in the list. We start the EmployeeDetails activity by creating an Intent.

Code highlights:

EmployeeList.java: in onListItemClick, we create a new Intent for the EmployeeDetails class, add the employee id to the intent using intent.putExtra(), and start a new Activity.

EmployeeDetails.java: The Employee details activity. We retrieve the id of the employee using getIntent().getIntExtra(). We then use a Cursor to retrieve the employee details.

employee_details.xml: A simple layout to display the details of an employee.

Step 5: Calling, Emailing, and Texting an Employee

In this fifth step, we interact with some of the built-in capabilities of our phone. We use Intents to allow the user to call, email, or text an employee. We reuse the EmployeeDetails Activity to allow the user to display the details of the manager of the selected employee.

Code highlights:

EmployeeDetails.java:

  • In onCreate(), we build an array of actions (call, email, sms, view manager) available to the user depending on the information available for the displayed employee (for example, we only create a “Call mobile” action if the employee’s mobile phone number is available in the database).
  • EmployeeActionAdapter is a custom list adapter that binds each action in the actions array to the action_list_item layout.
  • In onListItemClick(), we create an Intent corresponding to the action selected by the user, and start a new activity with that intent.

action_list_item.xml: Layout for each action in the actions list.

employee_details.xml: Updated employee details layout.

Step 6: Navigating Up and Down the Org Chart

In this sixth step, we create a new Activity to display the Direct Reports of the selected employee, allowing the user of the application to navigate up and down the org chart of the organization. We also improve some elements of the application: for example, we polish the user interface in several layouts, and we populate the database using an XML documents as opposed to the hardcoded sample data used in the previous steps.



Code highlights:

DirectReports.java: A new Activity to display the direct reports of a specific employee.

direct_reports.xml: The layout for the DirectReports Activity.

EmployeeDetails.java: “View direct reports” is added to the list of actions. When the user selects that action, a new Intent is created for the DirectReports Activity, and a new Activity is started using that Intent.

DatabaseHelper.java: Instead of populating the database with hardcoded sample data, the employee table is now created and populated from an XML file (sql.xml).

sql.xml: The xml file used to create and populate the employee table.

Related Article

I built the same application using Flex 4 and AIR for Android. You can check it out here.

165 Responses to Tutorial: Building an Android Application in 6 Steps

  1. Spencer October 10, 2010 at 12:27 pm #

    This example has helped me out greatly! But… I’m working with Android 2.1 and your step 4 package because I can’t seem to get step 6 working with 2.1 .

    My question is for step 4. Every time I modify values from DatabaseHelper.java the changes don’t show up. I must uninstall the application each time and reinstall it for changes to be seen.

    Is there any way you can help me out? I tried running an sql command at line 27 with no luck:
    db.execSQL(“DELETE * FROM employee”);
    db.execSQL(sql);

    • Tom May 19, 2012 at 9:05 pm #

      This is way old but in case anyone else is reading it;

      standard sql would be “DELETE FROM employee” – the asterix is only used to say select ‘everything’ e.g. all columns. note the delete here will empty the table more common would be to delete from where ID e.g
      “DELETE FROM employee where PERSONID = 1″ etc

    • AMD November 2, 2012 at 4:54 pm #

      @Spencer I am having the same problem. Can somebody help me

  2. manish November 8, 2010 at 6:36 am #

    Great Tutorial.

  3. hans November 25, 2010 at 2:53 am #

    Thank you for the great Tutorials.
    I have a question for step 4. If I don’t want to create database in class DatabaseHelper, so I want to copy my own database from assets into data/data/mypackage/databases. I had many tries but no luck. Can you help me? Thank you.

  4. Nathan5x December 1, 2010 at 12:58 am #

    Much needed one for getting started.

    Thanks a lot Chris.. :)

  5. Tanweer December 6, 2010 at 2:50 am #

    Hello,

    I am building an AIR application for Android device and want to capture the inputs through voice using Android Speech API .

    Can you please guide me how to do this.

    Regards,
    Tanweer

    • nnn February 9, 2012 at 8:56 am #

      fgsdtrg

  6. Gibby December 14, 2010 at 10:43 pm #

    Is there anyway to add a newline character to a value when you populate your database via sql.xml?? I’ve tried using \n but it just gets displayed

  7. Giumazzi December 15, 2010 at 4:35 pm #

    First I want to excuse for my previous post in the wrong section (air).
    I’d like to know how use a SQLite DB from asset folder to the application database directory.
    I have tried to modify the database helper but without result.
    Can you give me any help?

    Tanks in advance.

  8. Fedrix December 30, 2010 at 2:36 am #

    Thanks a lot Chris…… this tutorials helped me lot ….thank u once again…

  9. Gilad January 1, 2011 at 1:14 pm #

    Very nice tutorial!!!!! It really helped me! Thanks alot!!!

    I was slightly confused about the SQL part and would appreciate a more elaborate explanation.

    Thanks again!

    Gilad

  10. raj January 13, 2011 at 4:04 am #

    plz,tell me how to create and run android application in detail bcoz i dont know much about android appliaction

  11. raj January 13, 2011 at 4:05 am #

    am using eclipse3.4 help me how to create and run android application

  12. Super January 23, 2011 at 12:24 pm #

    A very nice tutorial! It helped me to understand some basic idea in Android programming. Thanks a lot!

    I’d suggest including the main.xml in the Code highlights of “Step 3″, the linkage of Seach button and Search function is defined in the xml. It’s really important. It takes me few hours to trace the reason why my program doesn’t work as expected (I try to follow the steps without download your source)….

  13. Pa1 January 25, 2011 at 4:56 am #

    Hey Christophe, Thanks a ton for providing such a Gr8 tutorial. Its extremely helpful.

  14. Reohn January 28, 2011 at 1:15 pm #

    Super, thanks for that comment! I had just spent an hour puzzling over that connection as well! Besides that little oversight this is a great tutorial! Thanks!

    • Jasbeer March 21, 2012 at 11:58 am #

      i found the tutorial very very nice my point of view .

  15. Reohn January 28, 2011 at 6:17 pm #

    I don’t know if anyone else had this problem, but in step four I change all my code (even downloaded the source code and pasted it directly into my project) but it is causing the emulator to crash (the application stopped unexpectedly). There are no errors or even warnings in my code. If I revert to step 3 the code still works. At step 4 however I can search and the list comes up, but when I click on one of the list items it closes. The debugger stops at a stack error “Native.Start.main(String[]) line: not available [native method] and in the details it says source not found. Any ideas?

  16. Bala February 1, 2011 at 11:03 pm #

    Awesome stuff mate. Excellent tutes and will go a long way in helping us get a start with Android.

    Cheers

  17. Steve February 4, 2011 at 2:00 pm #

    In step 4 I had to add a . in front of EmployeeDetails (so should be .EmployeeDetails — compare and make sure it looks the same as .EmployeeList), I believe this is to state it is a class off the package defined…hope this helps others stuck on step 4

    btw…great tutorial!

  18. Steve February 4, 2011 at 6:22 pm #

    …sorry, in my previous post, I am talking about updates in the AndroidManifest.xml file

  19. Ali February 11, 2011 at 6:26 am #

    Hi Christophe,

    What a great tutorial I love it and have been using it for my own project but I need a little bit help if that’s ok. I want to insert latitude/longitude in the database using ‘sql statements’ and convert that into an address (e.g. London Road, UK) and show it on google maps. Is it possible to do this and how? Thanks in advance.

  20. vlodimer February 20, 2011 at 7:08 am #

    this project is only for android v.2.2+?

  21. vedavyas March 1, 2011 at 3:50 am #

    Hi Christophe,

    I am new to the android world
    i want to display the data from sqlite in the form of list by using listview
    each list item should contain different icons
    plz…. help me

  22. Mike March 2, 2011 at 4:45 pm #

    Christophe

    I am new to flex development so i apologize if this is a simple problem to fix.

    I am using flex 4.5 burrito on windows 7.

    i keep getting a 2032 error when i try to run the application for the first time.

    RPC Fault faultString=”HTTP request error” faultCode=”Server.Error.Request” faultDetail=”Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: app:/assets/employees.xml" errorID=2032]. URL: ../assets/employees.xml”]
    at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()[E:\dev\hero_private_beta\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:345]
    at mx.rpc::Responder/fault()[E:\dev\hero_private_beta\frameworks\projects\rpc\src\mx\rpc\Responder.as:68]
    at mx.rpc::AsyncRequest/fault()[E:\dev\hero_private_beta\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:113]
    at DirectHTTPMessageResponder/errorHandler()[E:\dev\hero_private_beta\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:410]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()

    any ideas on how to resolve ?

    thx

    mike

  23. Marie Sheldon March 17, 2011 at 10:03 am #

    I solved my issue :

    For some reason, it is impossible to call a webserver from your device in Debug or Regular mode when the Network Monitor in Flash Builder is on. (!!!)
    So I just turned it off and my app started to work.

  24. me March 18, 2011 at 7:39 pm #

    Hello & Thank U for tutorials! ;)
    Especially for this one! :)
    Bookmarked page.
    Hopping get more tutorials! ;)
    Especially with GPS or Google Maps API :)

  25. Mobile Mass Money March 26, 2011 at 1:58 am #

    What an article. You have solved all the questions which newbies have in their mind. Keep up with this. With the help of your article even i can start making good applications

    Thanks

  26. Vivek Rathaur May 19, 2011 at 6:29 am #

    Thank you very much Sir. Your code and tutorial helped me a lot in escaping from the web of the ListViews. Now i can do better. Thanks a lot again.

  27. george May 25, 2011 at 4:01 am #

    thank you for your source code, coz it help help us big time..
    am having an error on EmployeeDetails on line 29
    known as EmployeeAction cannot be resolved to a type, also I dont know what it means
    help me out please coz am stuck

  28. george May 25, 2011 at 4:08 am #

    Mr. Cristophe
    am requesting if you can send me the codes
    that will help me create another interface
    for entering data into the Employee Directory

  29. Mike June 8, 2011 at 4:38 pm #

    New to Android and this was a big help!!

    Thanks for the well put together example and study of this matter.

    The only!! matter that was not explained was how to update the data .
    Is there a edit menu system hook that inflates on long item press,native to the OS.
    That allows the user to update the Name and Numbers etc.??
    Could you show how that would be done.

    Thanks for sharing,

    Mike

  30. Alvin June 20, 2011 at 1:03 pm #

    Hi Christophe,

    I’m on the biz dev team at Udemy, a website that lets anyone create and take a course online. We’ve recently had top-tier partners (with distribution to over 800,000 users) request courses on building Android applications using Adobe Flex.

    We’ve seen your 6-step Android tutorial and love your work. We’d like to invite you to create a course on http://www.udemy.com. On Udemy, we provide tools to build your own course, and its completely free. If you charge for your course, you keep 80% of the revenue you generate.

    Technical courses have been in huge demand on Udemy– Bess Ho’s “Learn to Develop an iPhone or iPad application in 4 weeks,” and Zed Shaw’s “Learn Python the Hard Way” have generated over $90,000 in sales in their first two months! The demand for development courses continues to grow but we don’t have enough to sell.

    Would you be interested in setting up a call to learn more?

    Best,
    Alvin Hsia

    P.S. Please feel free to forward this information on to anyone else you think may be interested

  31. android developer June 29, 2011 at 9:59 am #

    I love your post.
    Your writing is very helpful to me, who happened to learn about the android.

  32. moses July 6, 2011 at 6:05 am #

    nice tutorial but in the 3rd step i get an error in the main.xml that says the attribute onClick is not in the android package what can i do pliz help

  33. paul July 7, 2011 at 2:09 pm #

    Hi Chris

    I am developing a Flex 4 web application and need to create a php service that performs a multiple table insert of related tables.
    Kindly help with structure. Below are my tables

    clients (title, firstName, lastName)
    clientdependants (client_id, dependantNames, dependantDateOfBirth, dependantRelationship)
    clientssupportworker (client_id, supportWorker_id, sw_firstName, sw_lastName)
    riskissues (client_id, riskIssue)

    thanks

  34. Scott July 16, 2011 at 8:25 am #

    Great tutorial. One error though… Dwight is “Asst. to the Regional Manager” not “Asst. Regional Manager”. ;-)

    LOVE the contacts you used.

  35. vinod July 19, 2011 at 9:54 pm #

    I need to create a reusable component for Database use. If anyone can tell me how can I do this will be great help.

  36. Abdul latheef July 21, 2011 at 12:05 pm #

    Hi

    Thank you for your article , very useful for me.
    with regards
    Latheef

  37. Ram July 23, 2011 at 12:58 am #

    Hi sir,
    dis s nice tutorial for me. It’s good article. thx.

  38. Pallav July 23, 2011 at 12:31 pm #

    Really amazing tutorial. Liked it to the core.

    Thanks.

  39. swathi August 10, 2011 at 12:48 am #

    nice tutorial….how to add a image for the same…ie storing url of image in sqlite and download and display the image along with text data in the list

    • Reniel January 5, 2014 at 3:18 pm #

      i also want to know how to show images when url is on db

  40. george nyarko August 11, 2011 at 10:37 am #

    can someone please help me design an android application that will dial only one number when a user clicks on the icon or short. and how to compile it .a step by step manual will do me great.thank you all

  41. Ratih August 12, 2011 at 3:12 am #

    Thank you,
    It’s really simple tutorial but very very helpful.

    can i ask you, i cannot view the data (cannot read data from database). What’s my problem?

    Regards,
    RNg

  42. Thomas Francl August 19, 2011 at 5:26 pm #

    This is the first useful example that actually works! Thank you Christophe.

  43. Hema Venkataraman August 20, 2011 at 5:38 am #

    Thanks so much for the tutorial.
    I Created Family and FamilyDetails instead of employee
    I am stuck in the step 4. When I click on the list item it just opens an empty screen with the app name. It does not show up the details of the family. I used the log also whatever I logged after the call to Super create in the Family Details class also is not getting printed. I am doubtful whether it has started the Family Details Activity at all.

    The log final lines are:

    I/ActivityManager( 68): Starting: Intent { cmp=com.familydb/.FamilyDetails (has extras) } from pid 337
    I/ActivityManager( 68): Displayed com.familydb/.FamilyDetails: +524ms

    That is it. I am not seeing anything except the app name on the top and empty screen below.

    Can anyone help me ?

  44. Gianni December 14, 2011 at 7:18 am #

    Very useful. Code well built

  45. agus @ ROR Developer December 14, 2011 at 11:47 pm #

    Great tutorial! Now, how do we package the files (or turn it into an app) so that we don’t have to have our phone plugged into our computer to access it?

  46. yogi December 17, 2011 at 9:41 am #

    hey give the complete project zip……….

  47. Colin December 30, 2011 at 11:52 am #

    Hey,
    I am now learning to program in Android and I am trying your tutorials, I am having an issue with step 3 as the data is not showing up in the emulator. I believe I possibly typed something wrong but I cannot seem to find it. Can you assist me please.

  48. ANdres January 3, 2012 at 6:00 pm #

    Hi,
    Great tutorial!! and its funny how you used “the office” employees for your tutorial :)

  49. Ian Vilar January 13, 2012 at 1:54 am #

    Thank you very much for the tutorial, I’m starting android development and it helped me a lot to understand somethings.

  50. naveen January 17, 2012 at 7:40 am #

    how to set the different icon to the list in android…….plz help me

  51. Vik January 22, 2012 at 12:44 pm #

    How to show the content of the database to enable me to navigate up and down the org chart of the organization. My emulator can only show one at the time.

    great tutorial thanks

  52. shoe January 23, 2012 at 8:10 pm #

    Sorry to stray from the crowd but…
    In short your tutorial does noting more than provide the code. Youve simply thrown some rubbish example at us and then began with a sort of step 1… here’s the basics. Oh great i thought… then… step 2.. but by the time we get to step 2 we’re lost. Nice try though.

  53. tanu January 24, 2012 at 7:16 am #

    its nt enough for the begineer :(

    • Shruti Garg June 4, 2013 at 7:22 am #

      You can enroll in this course which is almost free and provides you free java course with professional android course from scratch to advance level and with interview material too.
      http://www.wiziq.com/course/21661
      Grab the deal.
      And become android app programmer.
      I am also enjoying the same :)

  54. Richard January 24, 2012 at 11:19 pm #

    Hi,

    When I download the tutorial code and import it into eclipse. I am greeted with the error message.

    [2012-01-24 20:41:39 - EmployeeDirectory1] Unable to resolve target ‘android-8′

    and

    Project ‘EmployeeDirectory1′ is missing required source folder: ‘gen’

    How do I go about resolving the issue?

  55. zahid January 27, 2012 at 11:51 am #

    Any body have full project code of this application plz mail me at zahidiqbal1990@yahoo.com I will be very thankful to him/her.

  56. Yunus February 1, 2012 at 2:04 pm #

    Unfortunately, only first record in the xml file added to the database. I cant make other records to insert to database. Is anybody have a similar problem like that ?

    • Yunus February 1, 2012 at 2:19 pm #

      It’s OK. cause of some missing escape chars.

      • Vik February 10, 2012 at 5:02 am #

        Hi Yunus,
        I have the same problem. What do you mean by escape chars.
        Thanks for your help

    • Henry February 16, 2012 at 6:57 pm #

      Hi,

      Did you manage to sort out how to insert new employees?

  57. Fadi Ramadan February 6, 2012 at 7:54 pm #

    How can i keep the list showing?
    I want the list to show up even if i didn’t input anything and when you use the search bar it kinda filters the items out!
    PLEASE help :)

  58. Fadi Ramadan February 8, 2012 at 12:16 pm #

    How can I autoclick the search item!
    I want to auto click the button!!!!
    so that the list comes up by defualt and then you can search it!

    • Steve March 11, 2012 at 4:46 am #

      Hi, Great tutorial, thanks.

      Can you tell me how i would auto populate the list view?

      When we enter the listview, it is blank until 1: we request search results, or 2: click the search button when the EditText is empty. I would like to populate the listview with the full contents of my database when we first enter the activity.

      Any help would be appreciated, thanks.

      Thanks,
      Stevie.

  59. Fadi Ramadan February 9, 2012 at 9:57 am #

    How can i add a photo ? to details and a thumbnail to the listview???
    Please help !!!

  60. Faruk February 9, 2012 at 11:04 pm #

    hi,
    When I started this tutorial this morning, I did not know almost nothing about how to write an application to android. but this article help me a lot.

    thanks for your greate work

  61. ekrem February 10, 2012 at 7:26 am #

    Great work

    I have question about your search routine

    cursor = db.rawQuery(“SELECT _id, firstName, lastName, title FROM employee WHERE firstName || ‘ ‘ || lastName LIKE ?”, new String[]{“%” + searchText.getText().toString() + “%”});
    your search parameter is sql searching whit LIKE parameter
    when type ” s” then starting search and then listing includade first name first character “s”
    how I can setting your search routine whitout LIKE parameter

    so when type only “s” character system dont result any record even include firstame start character “s”

    sorty my englısh

    regards

  62. ekrem February 10, 2012 at 2:10 pm #

    in search routine ,
    how I can showing screen “no employee found” if not finding matching employee name
    whit toast message

  63. AN Web Services February 13, 2012 at 2:01 am #

    WOW… Great shortcut to what i need to create list of social club members. Great article. Thanks for sharing :)

  64. Android app builder February 14, 2012 at 12:41 pm #

    Android is the phone whose market is day after day increasing. People are using the phone with android OS because it is too cheaper and provide the great stability to user of this.

  65. Henry February 16, 2012 at 6:28 pm #

    Hi,

    I am trying to add/remove emplyees in the sql.xml file but nothing seems to work. The original list just keeps loading everytime. can you help with this please?

    Thanks

  66. F. A. February 23, 2012 at 6:37 pm #

    Dwight is Assistant TO THE Regional Manager ;)

  67. Andolasoft February 24, 2012 at 5:16 am #

    This is quit interesting for android application developer. But if you have any question about Android problem then you can ask me.

  68. Gisela Novoa February 24, 2012 at 4:34 pm #

    Excellent article. I like your zero bs articles they’re the main reason I keep coming back here.

  69. carsanjay February 26, 2012 at 7:24 pm #

    this is tutorial for me who want to get started for android programming. thanks uncle !

  70. android app development February 27, 2012 at 12:31 pm #

    great share and its really good that build an application by own with out anybodies help too good keep on buddy

  71. Girish February 29, 2012 at 8:50 am #

    Hi, i’m new to android. tell me how to set the text which is fetched from database and in each row there should be two or more textviews with buttons.Please tell me how to implement this.U can send source code to my mail id girishbht5@gmail.com

  72. Muninder March 7, 2012 at 12:28 pm #

    Very nice article, just a comment please mention the pre-requisite as Android Version >1.5
    Coz Android 1.5 doesn’t support = > android:onClick=”search” />

  73. NarasingaMoorthy March 8, 2012 at 7:11 am #

    Hi,this is nice …its very use full for me..i am using step 6 in my android application..i created sql.xml file for inserted my data (id ,name and phone number)first time created and listed in my emulator…my question is inserted again record in my sql its not affected emulator..my problem is again and again repeated… please help me..

    thanks in advance…

  74. Muralidhar March 9, 2012 at 10:49 am #

    Nice tutorial!
    Found another cool tutorial on how to make a super simple android app super quickly here http://bit.ly/xisquz

  75. Matt March 10, 2012 at 6:54 am #

    Actually, Dwight Schrute is “Assistant to the General Manager”/

  76. Renato Fernandes March 15, 2012 at 7:20 pm #

    Is it just me or the tutorial misses the listener for the button? Well, I managed to fix this by including at the EmployeeList class the following inside onCreate() method:

    Button searchButton = (Button)findViewById(R.id.searchButton);
    searchButton.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View view) {
    search(employeeList);
    }
    });

    • winux July 16, 2012 at 5:03 pm #

      Is it just me or the tutorial misses the listener for the button? Well, I managed to fix this by including at the EmployeeList class the following inside onCreate() method:

      Button searchButton = (Button)findViewById(R.id.searchButton);
      searchButton.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View view) {
      search(employeeList);
      }
      });

      I think you are right I am nor trying to locate the exact location so I can insert the Button

    • AymanKun May 10, 2013 at 7:09 pm #

      What View object does employeeList attribute in search() refere to ??

    • AymanKun May 10, 2013 at 7:14 pm #

      please what View object does employeeList attribute in search() refere to ??

  77. herethere March 16, 2012 at 2:49 am #

    how do I change the database, changing the names, titles, contact nos., etc?

  78. anbu March 22, 2012 at 7:57 am #

    this tutorial is nice & help to me. i am new Android Developer . this field is very new for me. this tutorial is very helpful & GUIDE TO ME . THANKS.

  79. Dave March 27, 2012 at 9:15 pm #

    Can somebody tell me how you can change the database entries please? Thanks

  80. Android App Builder April 2, 2012 at 4:35 am #

    I agree with you.This is quit interesting for android application developer. But if you have any question about Android problem then you can ask me..Thanks for the great info!!

    • Aarvi April 18, 2012 at 2:01 pm #

      Hey Team,
      I was good till step 2, but in Step 3, I am unable to populate the list when click on the Search button.
      1. I have added the search method on the onClick event of Button.
      2. Also I have added the listener for the Button in the onCreate Method.
      Button searchButton = (Button)findViewById(R.id.btnSearch);
      searchButton.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View view) {
      search(lstViewResources);
      }
      });

      But both the things above didnt work out.
      Can you help me with this problem. Also one thing I was unable to SOP the values and strings, I dnt know if I am doing something wrong, but I think it must be pretty straightforward with the SOP command.

      Thanks in advance for the suggestions
      Aarvi

  81. Pierre April 2, 2012 at 6:17 pm #

    “we populate the database using an XML documents as opposed to the hardcoded sample data used in the previous steps”

    I can understand having your data in an XML file. Separating data from code sounds like a good idea. But raw sql statements? How is this better than your java Database helper?

  82. Aarvi April 18, 2012 at 1:46 pm #

    Thank you so much for the post.
    Its really great for helping the newbies like me.
    I have done good till step 2, but after that I am unable to populate the list.
    1. I have added the search method on the onClick event of Button.
    2. Also I have added the listener for the Button in the onCreate Method.
    Button searchButton = (Button)findViewById(R.id.btnSearch);
    searchButton.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View view) {
    search(lstViewResources);
    }
    });

    But both the things above didnt work out.
    Can any one help me with this problem. Also one thing I was unable to SOP the values and strings, I dnt know if I am doing something wrong, but I think it must be pretty straightforward with the SOP command.

    Thanks in advance for the suggestions
    Aarvi

  83. Prakash May 7, 2012 at 9:21 am #

    I am new to android. can u tell me how to save tamil words in android database and retrieve it.. i have searched many things but nothing worked out.. Help me..

  84. Chris May 17, 2012 at 6:37 pm #

    Id like to accomplish the same but I would like to import my Directory data from a .csv file. The data includes name, location, phone number, ect. I want the app user to be able to seach the directory based on different filters (location, ect). Once a person from the directory is loaded, Id like to have the option of the user uploading a photo that would appear on the bottom that entry page (in a photo album).

    Not sure how/If the 2 databases can be created using this method. i am also looking into AppInventor/Twdb.

    Thanks

  85. gayathri May 19, 2012 at 5:01 am #

    hello,
    i want to build an app in which after taking picture it should give some information can u guide me how to do this..
    thank you

  86. Carribean May 23, 2012 at 12:09 pm #

    WOW! This tutorial is Marvelous. Its so understandable and step-by-step guide.
    Please can you help me out.
    I am developing a GPS tracking app on Android 2.2 using Eclipse IDE and want to send Location updates between two Android phones so that both can track one another over the Map.
    Its like if some family members go somewhere then they can track each other’s location on the map using GPS by using this app.
    Please I dont know where to start, please I need help, its urgent.

  87. phontric May 28, 2012 at 7:20 am #

    Thank you So much, its hard to find tutorials that are Complex but simple to Understand this is one of those tutorials very simple concept of Using the SQLiteDb in android.

    Your concept was very useful to me so let me shear what i did with your concept.

    DBHandler CLass (Snipit)
    ================================================
    /////[OPEN THE DATABASE]/////////////////////////////////////////////////////////////////////////////////
    public DbHandler open() throws SQLException{
    Log.d(“chk”, “chk 3 dbhelper call open”);
    db = dbhlper.getWritableDatabase();

    return this;
    }

    /////[CLOSE THE DATABASE]///////////////////////////////////////////////////////////////////////////////
    public void close(){
    db.close();
    }

    ///[SEARCH SET]/////////////////////////////////////////////////////////////////////////////////////////////////////
    public Cursor search(String stext)throws SQLException{
    Log.d(“dbchk”, “Search fucation call”);
    return db.rawQuery(“SELECT _id, ”
    +” entery_name ” //Colm 0 get (ID)
    +”, Fcity ” //Colm 1 get
    +”, Fdate ” //Colm 2 get
    +”, lgps ” //Colm 3 get
    +”, SysMonth ” //Colm 4 get
    +”, SysYear ” //Colm 5 get
    +”, TimeEvent” //Colm 6 get
    +” FROM taggingTable ” //Table to GetFrom
    +” WHERE ” //Checker KEYWORD
    +” Post_Code ” //Colm to LookIn 1
    +” || ‘ ‘ || ” //Colm to LookIn 2
    +” Fdate || ” //Colm to LookIn 3
    +” SysMonth || ” //Colm to LookIn 4
    +” SysYear ” //Colm to LookIn 5
    +” LIKE ?”, new String[]{“%” + stext + “%”}); //Search String “stext” from the call Activity
    }

    ===========================================================================================

    CallingActivity class **note: this is any class that is goting to call the DB
    CallingActivity Class (Snipit)
    ============================================================================================
    DBHandler dbHler = new DHandler();
    Cursor cCursor;

    public void searchqry(View view){
    dbHdler.open();
    cCursor = dbHdler.search(searchText.getText().toString()); //What is passed is a String
    adapter = new SimpleCursorAdapter(this,
    R.layout.queryreturn,
    cCursor,
    new String[] {“entery_name”, “Fcity”, “lgps” , “TimeEvent” ,”_id”},
    new int[] {R.id.tvSrchImgName, R.id.tvSrchCity, R.id.tvSrchGPS ,R.id.tvSrchTime , R.id.tvSrchTID});
    monthList.setAdapter(adapter);
    dbHdler.close();
    }

    =============================================================================================

    My Calling Activity has not idea whats going on in the Database on the DBhandler
    this way you can apply this to other Activity which want to call the search.

    more of setup one time used many times

    but i dont take any create for this all the credit is Christophe for showing this concept
    Thank you

    I will add your site as a link to my Website i am a Website admin for many website i think i will add Links
    on them as well in relavent to the content here.
    Hit back on mrsweetps11v?a?gmail?dot?com

  88. Ronny June 16, 2012 at 8:28 pm #

    I just cant add this sign & not even like this & og & og \u0026.
    I har in the sql.xml like this –> INSERT INTO employee VALUES(27,’Enoksen& …….)
    but it´gives me error.
    not even this
    INSERT INTO employee VALUES(27,’Enoksen&’….) works
    help me how do i overcome the use of amp/& in the sql statement lines, please help me.

  89. suresh s June 27, 2012 at 5:08 am #

    I am new to android . Can someone help me to develop a battery saver for android 2.1.

  90. somebody July 20, 2012 at 6:41 pm #

    Why do people keep linking the Android to Windows for? The AndroidOS is Linux-based…

  91. Digital Publishing July 24, 2012 at 9:15 am #

    Thank you for this great tutorial..It helped me lot…Moreover those who are interested in creating new apps for them its very useful.Thanks for sharing this great article…NIce job…Keep sharing..

  92. angelo July 26, 2012 at 1:30 am #

    hi i just tried your application but when i click the button the application crashes am i missing something?i followed every step i am new to android could you please help
    thanks

  93. anil August 1, 2012 at 2:30 pm #

    nice tutorial,www.rtechinsane.in

  94. anil August 1, 2012 at 2:31 pm #

    nice tutorial,

  95. toyu August 4, 2012 at 5:36 am #

    Thank you.

  96. leela August 19, 2012 at 10:45 am #

    send me source code….

  97. Mike Pua August 22, 2012 at 7:33 pm #

    Very useful tutorial specially that search thing :) Been searching for actual code with layout on search feature for the list contents..

    Thanks.

  98. kalidas October 2, 2012 at 10:45 am #

    Great tutorials…

  99. unknown October 5, 2012 at 3:46 pm #

    where are the source codes?

  100. Philip October 27, 2012 at 12:15 am #

    I foudn an article which was quite good and easy to follow and create a simple app… http://www.vaidy.org/10/post/2012/10/basic-ui-tutorial.html

  101. Euge November 2, 2012 at 10:35 am #

    Hi

    Thanks for this tutorial, it is most informative. There is one small thing though:

    everything works fine up to step 5, when I make the changes to EmployeeDetails I get an error with EmployeeAction -
    protected List actions;
    gives the following error: “EmployeeAction cannot be resolved to a type”
    this is repeated for every instance of EmployeeAction – ideas?

  102. Ritesh November 16, 2012 at 11:53 pm #

    how can i connect my database table which is located in c://wamp/www/project/ i.e in wamp server?? means i want to connect my tables to this project, in wat location i need to change the code… please help me

  103. tlam December 5, 2012 at 5:51 am #

    Hello,

    I followed the steps till #4, and the sample doesn’t work anymore. My ListView acts as if it is not clickable and performs no action. Also, “SimpleCursorAdapter” is deprecated, so what other class I should use?

    Thanks.

  104. surekha December 13, 2012 at 5:42 am #

    but i want how to built an android application if required coding

  105. Moksudul January 12, 2013 at 6:53 am #

    Any body have full project code of this application? please mail me at sufal_cse@yahoo.com I will be very thankful to him/her.

  106. swedenonline January 14, 2013 at 12:42 pm #

    Simple and easy way to interact with database and different layouts :)

  107. Vikas February 25, 2013 at 8:34 pm #

    Hello Sir,
    I am getting an error in EmployeeList.java in onListItemClick() method. It says that the String cannot be converted into Cursor..
    Error is ClassCastException..
    Please help me.

  108. esta March 4, 2013 at 10:14 am #

    nice and cute tutorial. tnx for sharing

  109. آیلتس March 4, 2013 at 10:22 am #

    this tutorial is nice and useful for me.

  110. Wow, marvelous blog layout! How long have you been blogging for?

    you make blogging look easy. The overall look of your website is wonderful,
    let alone the content! Darline Herschel Emely Derrick Ester Ben Tonie Dino Teresa Rodrick Mitsue Randal Eusebia Stacey Lavonda Arthur Janise Brandon Kristan Jess
    Annmarie Wendell Allyn Derick Keila Curt Tammara Eldridge Bree
    Lenny Tona Luther Laurene Mariano Kitty Arturo Sarah Kennith Felecia Charley Rosie Donte Carmela Louis Norah Kip Melissa Johnathon Carma Gil Olivia Chauncey Fannie Oswaldo
    Denisse Gus Sharon Domingo Glinda Lesley Minta Irving
    Altagracia Dong Kathryne Markus Lori Alfredo Candie Steven Lara Hiram Tawna Dario Deeann Loren
    Tracey Wesley Corey Miles Ja Garth Geri Carter Easter Harris Laurel Kent Moon Stephen Madonna Val Carleen Neal Liberty Jerold Lady Alejandro Billie Miles

  111. NN March 11, 2013 at 2:24 am #

    I have already done try this coding but it does’t work for step 3 and 4 that related with database.Data from database it does not display, so i need help how to settle this problem.

  112. Lamar May 18, 2013 at 12:30 pm #

    Awesome blog you have here but I was curious if you knew of any discussion boards that cover the same topics
    discussed in this article? I’d really like to be a part of online community where I can get responses from other knowledgeable individuals that share the same interest. If you have any recommendations, please let me know. Thanks a lot!

  113. Shruti Garg June 1, 2013 at 5:09 am #

    Hello,
    Very nice and great blog it is.
    Still anybody has some sort of problem or wanna learn android professionally..
    Can take online Certified Professional Android App Development Course follow the following link
    http://www.wiziq.com/course/21661

    I am also a Certified Professional Android App Programmer and I am enjoying converting my innovative ideas into Mobile Apps.
    So be a certified trainer and be a professional Android App developer.

    I was not strong in programming at that time but then they provided me free java course to fill my gaps.
    So Keep Leaning | Have Fun

  114. Marcelo June 10, 2013 at 7:25 am #

    Hi Christophe,

    Thank you for the examples. Very helpful. However I’m looking for an example that will have an expandable list with clickable links that will lead to screens that match a criteria. Thanks in advance.

  115. rohit July 14, 2013 at 4:16 pm #

    Hope you Doing well. I found your website is very well design and You will get more visitor on ur website or make real money with converting ur website into android application and published into Google play store, I am an experienced android application developer and I can easily convert ur website or blog or whatever u need to develop from me i can do it easily. I am working in this field since four years. I have an very much knowledge about how to develop apps and how to published apps into Google play store. It will also increase traffic on ur website. Your website will be turn into android application and user will easily access to ur site through Google play store. Your website will look same as in Web version. I found that ur website can be highly repudiated by convert into android apps. I will share my full information with you. Interesting contact me back.

  116. Lee Wright July 24, 2013 at 4:46 am #

    Excellent work.. do contact us if you want to have a website like this

    • johnZed February 2, 2014 at 1:09 am #

      i have developed several android apps give me a detailed process to add them to google play store

  117. anand July 27, 2013 at 3:53 am #

    I love this tutorial, I want to get the employee list without search just show the list and have a search (filter like normal phone contacts) in action bar. Sorry I am new to android. I would appreciate if your post to code or give a downloadable source

  118. Ambar August 17, 2013 at 2:32 pm #

    Languages

    Video Tutorials Collection

  119. saravana panidan.s September 11, 2013 at 5:30 am #

    I am a new for the android application development. can you help me for how to design a phone layout and how to run with android sdk.

  120. ipa to apk converter September 12, 2013 at 5:04 am #

    Wow, incredible weblog structure! How long have you
    ever been running a blog for? you make running a blog glance easy.
    The overall glance of your website is great, as well as the content!

  121. Bogi September 23, 2013 at 10:23 am #

    Dear,
    I tried to run your application, however, does not work for me.
    I get a box and search button, there is no list of names from the database.
    Thank you in advance for your help

  122. Godly T.Alias October 1, 2013 at 2:25 pm #

    Checkout this link for having a view into the source code of an open source android application
    http://godlytalias.blogspot.com/2013/09/gtacampus-android-application-source.html

  123. Parveen Joshi October 3, 2013 at 8:22 am #

    so nice!!!

  124. dev October 8, 2013 at 2:56 am #

    http://androidtutorialsrkt.blogspot.in/……
    good one……..

  125. Gurmeet Singh October 17, 2013 at 4:22 am #

    thnks and thanks

  126. Jon November 26, 2013 at 9:57 am #

    I am writing an app that queries an already created database (read only).

    How do I connect to the database via its file?

    All examples I have seen create the database on the fly.

  127. weight bench December 2, 2013 at 5:29 pm #

    Great post. I was checking continuously this
    blog and I am impressed! Very useful information specifically the last part :) I care
    for such info a lot. I was looking for this particular information for a long time.

    Thank you and best of luck.

  128. Alley January 23, 2014 at 7:03 am #

    How to use QR Codes – Sales Lead Maximizer is one of the best organizations when it comes to knowing how to measure marketing response or use software for building mobile websites.increasing the sales pipeline or measuring marketing response. You’ll have the consolation of knowing our group is with all of you the way, ceaselessly upgrading our administration as customer criticism and business sector advancements unfold.

  129. Andrew Miller January 25, 2014 at 12:35 am #

    Nail Courses – Becoming a qualified nail expert and taking in the specialty of applying nails is an incredible method for profiting and our nail courses, which are completely authorize nail recognition’s and NVQ level courses blanket every one of the five nail frameworks incorporating Manicure, Gel, Fibreglass, Silk and Acrylic

  130. anish January 28, 2014 at 3:51 am #

    Here is discussion forum for android developer questions http://skillgun.com/android/interview-questions-and-answers

  131. Robert Walker January 29, 2014 at 3:16 am #

    salesleadmaximizer :
    Software For building Mobile Website – Acquire the in-profundity examination of the present situation in the industry and increment the leads you get for your business. SLM has been produced to give your business, a way to climb the stairs of triumph and get the routines for expanding the deals pipeline.

  132. runit February 6, 2014 at 12:34 am #

    i am getting an error that R is not an instance to a variable. how to remove it. plz help

  133. Varun February 18, 2014 at 12:08 pm #

    Thanks for sharing this good article. http://www.blogercup.com .

  134. Edward February 28, 2014 at 10:24 am #

    Dear Android App Engineers/Programmers,

    Anyone interested in making Android App for survey in Retail Stores?
    The app should be supported to any type of Android Phone/Tablets at any screen size.

    Currently I have around 300 Questions, which answer vary from question to question, for Example – some are YES /NO only, some are Rating 1, 2, 3 and some are Remarks, Quantity etc. So overall 14 types of possible answer for each question.

    There should be following feature in the Android App:
    1. Dynamic enough to support on any screen size and Android versions
    2. User login option should be there with photo.
    3. Have facility to change any questions or Add any questions as well as answer
    4. It should give the result on my domain in SQL as well as Excel format
    5. User can take photo while answering any questions
    6. Administrator can create new users, update and delete users for login.
    7. There should be 5 Questions at a time on the screen in two languages English and Arabic
    8. The user can do survey for only the Nahdi Store (750 name and code will be provided)
    9. It could store the history data also as per date of survey for each store
    10. Preferred Database in SQL Server 2008

    If interested, kindly contact me via email add with reply:
    Name:
    Estimated Time to Finish Project:
    Quotation:

    Thanks and Best Regards,

    Edward Lumanlan
    Space Planner

  135. Edward February 28, 2014 at 10:26 am #

    lumanlan.eb@alnahdimc.com

  136. Anthony March 23, 2014 at 6:02 pm #

    How to add an image to the Employee List Search Results?? Urgent Help!

  137. patchwork kilim March 24, 2014 at 5:07 am #

    http://coenraets.org/blog

  138. Alannah April 8, 2014 at 7:53 pm #

    We are creatures of habit that are basically lazy and love to
    leave things until the last minute. The trend of collecting personalized charms that mark
    milestones and occasions became popular in America round the mid 20th century.

    You should use soap with a minimum since some soaps can contain heavy chemicals, which slowly degrade your silk fabric.

  139. labour.gov.za April 10, 2014 at 5:31 am #

    Kids are under more pressure than ever to succeed in school.
    Find out more by shopping on the web at your leisure
    and in order to compare and contrast the different prices. Fortunately, these
    days baby bags come in manly colors and designs.

  140. Puzzle And Dragons Hack April 10, 2014 at 10:36 am #

    Hi there, this weekend is good designed for me,
    for the reason that this moment i am reading this great educational post here at my house.

  141. seo quick tips April 22, 2014 at 1:55 pm #

    I have read so many articles or reviews regarding the blogger lovers except this post is genuinely a pleasant piece of writing, keep it up.

Trackbacks/Pingbacks

  1. Android - Programming Resources - September 21, 2011

    [...] Building an Android Application in 6 Steps In this tutorial, you will learn to build an Android application in just 6 steps. [...]

  2. More SQLite | CPSC X81 BLOG - February 14, 2012

    [...] Example 4 Tutorial Uncategorized ← Great Database link. /* */ [...]

  3. How To Make Android Apps: Top Resources and Tutorials - April 11, 2012

    [...] [Visit Site] [...]

  4. Android Codes | Zakaria Bin Abdur Rouf - September 14, 2013

    [...] http://coenraets.org/blog/androidtutorial/ [...]

  5. Sample iOS Application with Xcode, Objective-C, Storyboard, and Core Data | Christophe Coenraets - November 21, 2013

    [...] native Android version of the same application a couple of years ago as well. It’s available here, and probably needs to be [...]

  6. Tutorial: Building an Android Application in 6 Steps | Appsdb.net - March 20, 2014

    […] Source: coenraets […]

  7. Tutorial: Building an Android Application in 6 Steps | Christophe Coenraets | kapsirma's Blog - March 22, 2014

    […] http://coenraets.org/blog/androidtutorial/ […]

Leave a Reply