guide=true page.title=Sample Code @jd:body
Sometimes, the best way to learn how things are done is to look at some code. Here, you can browse the source of some sample Android applications that are included in the Android SDK.
Each version of the Android platform available for the SDK includes a full set of sample applications (which may vary between different versions of the platform). You can find the samples in your SDK at:
<sdk>/platforms/android-<version>/samples/
You can easily create new Android projects with these samples, modify them if you'd like, then run them on an emulator or device. For example, to create a project for the API Demos app from Eclipse, start a new Android Project, select "Create project from existing source", then select {@code ApiDemos} in the {@code samples/} directory. To create the API Demos project using the {@code android} tool, execute:
android update project -s -n API Demos -t <target_ID> -p <path-to-platform>/samples/ApiDemos/
The pages below provide an overview of each sample application (available with most platforms) and allow you to view the source files in your browser.
Some of the samples in this listing are not yet available in the SDK. While we work to update the SDK, you can download the latest samples as a ZIP file here.
For more sample applications, check out apps-for-android, a collection of open source applications that demonstrate various Android APIs.