History:
01.jul.2009 : Initial version for Ubuntu 9.04 and Android SDK 1.5 (Cupcake).
16.sep.2009 : Upgraded to Android SDK 1.6 (Donut).
27.oct.2009 : Upgraded this guide to Ubuntu 9.10 (Karmic Koala).
  The older version for Ubuntu 9.04 (Jaunty) is here...
08.nov.2009 : Upgraded to Android SDK 2.0 (Eclair).
  Android 2.0 highlights...
10.oct.2010 : Ubuntu 10.10.
26.jan.2011 : Android SDK r09-linux with support for Honeycomb...(tablet computers).
10.sep.2011 : Android SDK r12-linux and Ubuntu 11.10 (Oneiric).
: Video of new features and tools...

Developing applications for the Google's Android phone
on Ubuntu 11.10 (Oneiric)

The Eclipse IDE and Ubuntu is a very powerful combination for professional development work on the Android Phone.

This guide will show you how to install the Eclipse IDE and Android Development ToolKit on Ubuntu Linux.
You will also learn how to create a basic Android application and run it in an emulator or real phone.
This is your target.
Your target
Failure is not an option here.
The amazing calculator in the picture is for sale on the Android Market Place.
See http://www.futuredesktop.com

Pre-requirements

Basic knowledge of Unix/Linux would be nice. Study pocket guide.pdf
You should also know how to program in Java or similar languages. Study http://java.sun.com/tutorial

We are now going to install these programs

• The Ubuntu Linux Desktop.
• Sun's Java Runtime (JRE) and Development Kit (JDK).
  Java Runtime is only needed to run the Eclipse IDE. Android has its own optimized Java VM (Dalvik).
• The Eclipse IDE.
• The Android Software Developer's Kit (SDK).
• The Android Developer Tool (ADT), a special Eclipse plugin.
---------

0) Install Ubuntu Desktop

Start by installing the lastest Desktop version of Ubuntu Linux. Follow this guide...
You may either choose 32 or 64bit Ubuntu. Both systems suit well.
Fulfill all 8 steps ;-)

Ubuntu Linux has become the #1 development platform for Google's Android.
And Android itself is powered by Linux too.

Many benchmarks witness.. of Ubuntu's powerfulness and suitability for this task.
---------

1) Install Java Runtime

Notice: http://www.4pmp.com/2009/12/syntax-error-parameterized-types-are-only-available-if-source-level-is-1-5/
Syntax error, parameterized types are only available if source level is 1.5

MUST HAVE SUN-JAVA6?
openjdk-7-jre?
sudo update-alternatives --config java


You can either use Oracle's official Java or the free OpenJDK Java solution. Both work well with the Eclipse IDE.

First,
start gnome-terminal from the Ubuntu's Dash. Search for "terminal".
Take a look at this picture
gnome-terminal

Now choose either Alternative 1a or 1b.

Alternative 1a: Install OpenJDK Java Runtime.

First, remove any conflicting Java-packages. (do not copy or type the $)
$ sudo apt-get remove --purge sun-java6-* gcj

Then install OpenJDK Java JRE (runtime)
$ sudo apt-get install --reinstall icedtea6-plugin openjdk-6-jre

Support for 32-bit libraries.
If you are running 64bit Ubuntu, install support for 32bit libraries. This is a very important issue !
The various Android tools will not work in 64-bit Ubuntu unless you install this package.
This package may not exist in 32-bit Linux.

$ sudo apt-get install ia32-libs


Alternative 1b: Install Oracle's official Java Runtime.

Complete the step 6) of this guide.... (all steps) and install  Sun's  Oracle's Java solution. I repeat the commands here.

Remove all conflicting packages
(do not copy or type the $)
$ sudo apt-get remove -y --purge openjdk-6-jre gcj
$ sudo apt-get remove -y --purge openjdk-6-*

Activate Canonical's Partners repository. This is where the Oracle's official Java comes from. 
Run the following command only once. I do afraid it may add duplicate lines to your /etc/apt/sources.list file. Edit the file manually if that happens.
$ sudo add-apt-repository "deb http://archive.canonical.com/ maverick partner"

Reload the package list and do the installation. Run
$ sudo apt-get update

$
sudo apt-get install --reinstall -y sun-java6-jre sun-java6-jdk sun-java6-fonts
If you need to confirm the license, press TAB-key or arrow-keys to move the cursor in the text window.

Support for 32-bit libraries.
If you are running 64bit Ubuntu, install support for 32bit libraries. This is a very important issue !
The various Android tools will not work in 64-bit Ubuntu unless you install this package.
This package may not exist in 32-bit Linux.

$ sudo apt-get install ia32-libs

Note: You do not strictly need the Java Development Package (
sun-java6-jdk). The Java runtime *-jre should be enough.
Why? Because Android is emulated in a virtual container that runs Linux kernel and it has its own Java-interpreter/byte compiler called Dalvik.
We do only need the *-jre to run the Eclipse IDE. There is no need for *-jdk. Is this right?
Do you agree?
---------


Notice:
You can easily check which Java-packages you have installed. Simply type
$ dpkg -l | grep jre

ii  openjdk-6-jre
It will report "openjdk-6-jre" for Open Java and "sun-java6-jre" for Oracle's official Java solution.

Notce:
You can always re-select and reset the java by running
$ sudo update-alternatives --config java



2) Download and install the latest Eclipse IDE

The Ubuntu's Eclipse package does not have all the required features. Remove it !
$ sudo apt-get remove eclipse

We have to download the latest Eclipse IDE (named Galileo) from eclipse.org.
Browse to  http://www.eclipse.org/downloads and download the "Eclipse IDE for Java EE Developers (210 MB)"
Take either 
32bit... or 64bit... Linux version depending on your Ubuntu OS.

Type uname -a command
if in doubt. It should report i686 ot i386 (for 32bit) and X86_64 (for 64bit Linux).

Extract the tar.gz file to your $HOME folder.
See picture 2a.
Install Eclipse IDE

It should create an "eclipse" directory in your $HOME area (like /home/username/eclipse/).

Now check the eclipse directory.
$ ls -l $HOME/eclipse/

drwxrwsr-x   2 moma moma   4096 2011-06-15 08:51 about_files
-rw-rw-r--   1 moma moma  18909 2011-06-14 00:18 about.html
-rw-rw-r--   1 moma moma 227637 2011-06-15 08:50 artifacts.xml
drwxrwsr-x   5 moma moma   4096 2011-06-15 08:51 configuration
drwxrwsr-x   2 moma moma   4096 2011-06-15 08:51 dropins
-rwxr-xr-x   1 moma moma  71023 2011-03-21 21:05 eclipse 
<--- eclipse executable
-rw-rw-r--   1 moma moma    410 2011-06-15 08:51 eclipse.ini
-rw-rw-r--   1 moma moma  16536 2005-02-26 00:53 epl-v10.html
drwxrwsr-x 139 moma moma  20480 2011-06-15 08:50 features
-rw-rw-r--   1 moma moma   9022 2006-12-11 17:04 icon.xpm  <--- icon image
-rwxr-xr-x   1 moma moma 335360 2006-12-11 17:04 libcairo-swt.so
-rw-rw-r--   1 moma moma   8951 2011-02-04 21:39 notice.html
drwxrwsr-x   5 moma moma   4096 2011-06-15 08:48 p2
drwxrwsr-x  26 moma moma  73728 2011-06-15 08:50 plugins
drwxrwsr-x   2 moma moma   4096 2011-06-15 08:51 readme

Looks good to me.
---------

3) Create a launcher icon for the Eclipse IDE

Press the right-mouse-button on the desktop surface and select "Create Launcher..." from the popup-menu.
The command should point to $HOME/eclipse/eclipse. The eclipse directory contains also an icon bitmap (icon.xpm).
Pick the icon (icon.xpm) from that directory.

See picture 3a.
Create launcher
---------

4) Download Android SDK (Software Developer's toolKit)

Android SDK contains the application framework; widgets, views and other Java classes.
It also comes with many tools (in the tools/ directory) and most importantly, the Android Emulator.

Browse to http://developer.android.com/sdk/... and get the very latest Android SDK (Software Development toolKit).
Take the newest SDK version for Linux (i386). It will work on all Linux versions.

I simply click the android-sdk_r12-linux_x86.tgz... link to start the download and accept the license agreement.
This latest SDK supports several Android paltforms; Android platforms 1.5, 1.6, 2.0, 2.1, 2.2, 2.3 and Honeycomb (for tablet computers).

Again,
extract the files to your home area.
See picture 4a.
Install Android SK

It should create an "android-sdk-linux_x86/" directory, like /home/username/android-sdk-linux_x86/.

Check the files.
$ ls -l $HOME/android-sdk-linux_x86/

drwxr-xr-x 2 moma moma 4096 2011-06-23 01:54 add-ons
drwxr-xr-x 2 moma moma 4096 2011-06-23 01:54 platforms 
<-- SDK versions and samples (initially empty!)
-rw-r--r-- 1 moma moma 1097 2011-06-23 01:54 SDK Readme.txt
drwxrwxr-x 5 moma moma 4096 2011-06-21 14:03 tools 
<-- some important tools.

Looks good !

Notice: You don't need to remember and write long file and path names on the command line.
Press the TAB-key and command line will auto-complete file and path names among other values.

The android-sdk-linux_x86/platforms/
directory is initially empty. We will fill it with SDK versions/platforms later.
---------

5) Add tools/ to your $PATH

I am considering to remove this point.
Move to step 6.

The $HOME/android-sdk-linux/ directory contains a subdirectory called tools (in my case it is /home/moma/android-sdk-linux/tools/).
If you want to access these tools from any other directory, you must add the tools/ path to the global $PATH variable.

Edit your $HOME
/.bashrc resource file
$ gedit $HOME/.bashrc
and add the following blue line to it.
export PATH=${PATH}:$HOME/android-sdk-linux/tools/
Gnome-terminal reads the .bashrc at start. The change take effect after your close and restart your terminal windows.

Then check the $PATH with
$ echo $PATH
---------

6) Install Android plugin for the Eclipse IDE

In this step we will install the ADT-plugin (Android Developer Tools plugin) for the Eclipse IDE.
It
will make Android development and debugging very easy and straightforward.

First, read the Android's quick start guide...

Now start the Eclipse IDE and select Help -> "Install New Software..." from the menu.
See picture 6a.
Install ADT-plugin

The "Install" dialog for new software should appear.

Then press the [Add...] button and fill in these values.

Name: Android plugin
Location: https://dl-ssl.google.com/android/eclipse/

See picture 6b.
Install ADT-plugin

Wait until the status text changes to "Developer Tools".
Then checkmark, select the "Developer Tools" and all its subitems as shown in the picture 6c.

See picture 6c.
Install ADT-plugin

Click the [Next...] button to move forward.
See picture 6d.
Install ADT-plugin

Do nothing in this dialog.

Again, click the [Next..] button to move to the final dialog and accept/confirm the license text.
See picture 6e.
Install ADT-plugin

Click the [Finish] button.

Click [OK] if you see a security warning.

The download and update may take a few minutes time. Let it run.

Restart the Eclipse IDE after installation.
---------

7) Install SDK packages and components

In the step 6 we installed the SDK but it contains only some indispensable tools but not the SDK frameworks (platforms) for development.
We will now download and update the various SDK frameworks/platforms.

You may first read
http://developer.android.com/sdk/installing.html#components

7a) Assign SDK's location in the preferences.

In the Eclipse IDE, select Window -> Preferences from the menu.
See picture 7a-1.
Window -> Preferences
 
Then choose Android from the list and set the "SDK Location" as shown in the picture 7a-2.
Use the [Browse...] button and locate your android-sdk-linux_x86/ directory.

SDK Location

Press the [Apply] button to confirm it.
---

7b) Install platforms and components

Select Window -> "Android SDK and AVD Manager" from the menu.
See picture 7b-1.
Window -> Android SDK and AVD Manager

Then select "Available Packages" from the list. Then pick the relevant components and Android-platforms for your needs.
Simply select all of them if you do know know better. In my case, I select all but the SDK Platform Android 1.5 component.
See picture 7b-2.

Window -> Android SDK and AVD Manager

Press the [Install Selected] button to start the installation.
Confirm the license and let it run. This step may take a few minutes to complete.

Click [Accept] or [Accept All] to confirm the licenses.

The download may take a few minutes.
------------

8) Create Android Virtual Devices (AVDs)

Andoid Virtual Device (AVD) determines various characteristicas of the emulator instance you run.
You must create at least one AVD to start with.
I usually create one AVD for each screen size (small, medium and large) so I can test the GUI of my programs.

Read: http://developer.android.com/guide/developing/tools/avd.html

Start the AVD manager from the Window -> "Android SDK and AVD Manager" menu.
Then select the "Virtual Devices" option.

Click the [New...] button to create a new AVD (Emulated Android Device).
Give it a descriptive name like "device-HVGA".

Create couple of AVDs.

See picture 8a.
Window -> Android SDK and AVD Manager

Click the [Start...] button and test the emulator devices.
See picture 8b.

Window -> Android SDK and AVD Manager

Notice: 64bit Ubuntu users may encounter the following error message.

[2011-09-05 21:00:51 - SDK Manager] Failed to create the SD card.
[2011-09-05 21:00:51 - SDK Manager] Failed to create sdcard in the AVD folder.

Installing the ia32-libs package should fix this error.
$ sudo apt-get install ia32-libs
--------- 
---------  ---------  ---------

Congratulations !
Window -> Android SDK and AVD Manager

You are now ready to start app development for the Android phone.
Besides having a lot of fun you may even earn some money.

9) Create your first Android application

In this step we'll create a basic Android application (Hello Android) and run it in the emulator.

This example is from http://developer.android.com/guide/tutorials/hello-world.html
Study it first.

Now, start the Eclipse IDE.

From the main menu select File -> New -> Project.
See picture 9a.
Creating Android app

Further, select "Android Project" from the list.
Picture 9b.
Creating Android app

In the project dialog, punch in the following values.
Project name: Hello Android 2.1
Build target: checkmark the Android 2.1 option.
Application name: Hello Android    (this will apear as application title in the phone)
Package name: com.testcompany.helloandroid    (you might use your own company domain as package name)
Create activity: HelloAndroid    (this must be a valid Java class name. It extends the Activity class)
Min SDK version: 7    (7 means Android SDK 2.1)

See picture 9c.
Creating Android app
Click the [Next] and [Finish] buttons to complete the project.
--


Expand the project itemsand study the
HelloAndroid.java file (in the src/com.testcompany.helloandroid/ folder).
Study also the res/layout/main.xml file. It determines the application's GUI.

The final result should look like this.
See picture 9d.
Creating Android app
Note that the package name at the top must match the package name in res/AndroidManifest.xml file.

Finally compile and run the application in the emulator.


Select Run -> "Run" from the menu (or press the CNTR + F11 keys).
In the "Run As" dialog choose "Android Application".

It should compile and start the emulator for Android Phone.
It may take a few seconds to fire the emulator at the first time.

Notice:
You may need to clean the application before compilation. Do cleaning from the Eclipse's Project -> Clean menu.

The final result should be this.
Creating Android app

Notice: You may need to press (or click) the emulator's [Menu] button when the it launches at first time.

Do not close the emulator. All subsequent runs will reload your application automatically.
Press CNTR + F11 to change the phone's orientation; portrait, landscape.

Learn to know the Eclipse's Run -> Run Configuration... dialog.
There you can decide which emulator (AVD) to start as default and wheather to start it automatically or manullay (by selecting it).


Learn more about the Android emulator: http://developer.android.com/guide/developing/tools/emulator.html

http://www.youtube.com/watch?v=Oq05KqjXTvs

Learn more about the emulator
http://developer.android.com/guide/developing/tools/emulator.html

---------

Important: Study the examples and API-demos that come with the emulator.
Take a look at this picture.

Read more about the demos.
List of samples:
http://developer.android.com/resources/browser.html?tag=sample
+
http://developer.android.com/resources/samples/ApiDemos/index.html

10) Running apps on a real hardware

We will now prepare your Android phone for application development and debugging.

10a) First, set your phone for USB debugging.
In your Android phone, go to Settings -> Applications -> Development menu, and make sure "USB debugging" is checked (activated).
See picture 10a.
Running apps on a real hardware
--

10b) Connect your phone to your computer via USB cable.
--
Please read this manual section before continuing.
http://developer.android.com/guide/developing/device.html#setting-up


Then in your Ubuntu Linux.

10c) Type the lsusb command to list all USB devices.

$ lsusb
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
...
Bus 001 Device 003: ID 0bb4:0c01 High Tech Computer Corp.  <--- T-Mobile G1 Android phone (if I had one).
Bus 001 Device 003: ID 0bb4:0c02 High Tech Computer Corp. Dream/ADP1/G1 Phone. <--- HTC Hero Android phone.
...
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

The listing shows that my phone has VendorID 0bb4 which is the manufacturer HTC and ProductID is 0c02, my HTC Hero phone.
The listing looks correct.

The above manual page... has a list of
manufacturer/vendor IDs.
--

10d) In Ubuntu, create a new rules file for these vendor:device IDs.
Type this command to create the file
.

$ sudo gedit /etc/udev/rules.d/51-android.rules
Add the following blue lines (rules) to it, but type in correct idVendor and idProduct values.
These values may be totally different in your case.
Copy the actual values from your lsusb listing !

SUBSYSTEMS=="usb", ATTRS{idVendor}=="0bb4", ATTRS{idProduct}=="0c01", MODE="0666"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0bb4", ATTRS{idProduct}=="0c02", MODE="0666"

See picture 10d.
Running apps on a real hardware

Save the file.
--
10e) Restart your computer !
The Eclipse IDE will now detect your your phone when plugged to the computer.
And you can pump applications to the phone.

EDIT: Instead of reboot, you could also type
$ sudo restart udev
--

10f) Now turn to the Android's adb tool and list all devices and emulators.

Cd into the tools/ directory.
$ cd $HOME/android-sdk-linux_x86/tools

List all Android type devices and emulators.
$ ./adb kill-server
$ ./adb devices
List of devices attached
emulator-5554   device     <-- emulator instance/window.
HT98AL801622    device     <-- The real HTC Hero phone !


You can now access your phone from the Eclipse IDE and run/debug applications on it.

I like to set the
"Deployment Target Selection Mode" to Manual.
Start Run -> "Run Configurations..." dialog from the Eclipse's menu. Select your Android application at the left side,
and click to the [Target] page. Set the "Deployment Target Selection Mode" to Manual.
This will let you choose between the devices (your phone and emulators) where to deploy and run your program.
----

10g) Connecting Android-phone to a computer.
Accessing music and photos etc.

It is quite easy access the the phone's memory card from Linux.

First, connect the phone to your computer via USB cable.

Then switch on the phone and enable the connection (mounting).

Do this:
On the phone, use your finger + pull and expand the notification area so you can see all messages.
Notice that the notification list begins from the very top, and you must pull downward to see it.

One of the messages should concern the "USB-connection".
Select the "USB connection" message. Then click the [Mount] button.
See picture 10g1.
Mounting Android's memory card
It will enable file transfer between the phone and computer.

See pictures 10b3 - 10b5.
Now you can access (read and write) files
from/to your phone and the Linux Desktop.

Your photos and videos


And music files

Mounting Android's memory card Mounting Android's memory card Mounting Android's memory card

Notice: Unmount the memory card after usage.
It ensures that all data is written to the device.
See picture 10b6.
Mounting Android's memory card

I usually also right-click the memory card icon on my desktop and select
"Unmount" or
"Unmount Volume" from the menu. Then it should be safe to unplug the USB-cable.

---------

11) Examples

The Android SDK comes with many good samples.

The samples lay in /home/yourusername/android-sdk-linux_x86/samples/ directory.
Please read: http://developer.android.com/resources/samples/get.html

Start Nautilus file manager (from Ubuntu's Places -> "Home Folder" menu ;-) and investigate the files.
See picture 11a.

Training, training and more training.

You can pick and run the samples one by one, but it's easier to import the entire "ApiDemos" collection to the IDE.
Do this:

First close all projects from the File -> "Close All" menu.

Select File -> New -> Project from the menu.

See picture 11b.
Training, training and more training.

Then tick the "Create project from existing source" option and pick the .../android-7/ApiDemos/ project.

See picture 11c.
Training, training and more training.

Click the [Finish] button to complete the import.

You may need to clean the project before it compiles right. From the menu run Project - >Clean.

Youy must also create a virtual device for the
.../android-7/ApiDemos/ project. It is based SDK 2.0.1.
From Window -> "Android SDK and AVD Manager", create a device that that targets SDK 2.0.1.
-----

Alternative method using the File -> Import menu.

Select File -> Import from the menu.
Then choose import General -> "Existing Project into Workspace".

Pick the .../samples/android-8/ directory and import it to the IDE.

There is a minor catch in the source code. Open the "DeviceAdminSample" file and set the cursor
on the source code and press CNTR + SHIFT + O.  It will re-fresh the class' "import..." list.

Press CNTR + S to save the file.  Now the red error markers should disappear.


Note: The CNTR + SHIFT + O key combination is very important. It will help you to auto-complete the class "import ..." list.

----

TODO

14) Using the Android tools

The Android SDK includes several handy tools.
Read: http://developer.android.com/guide/developing/tools/index.html

Take a listing of the tools directory.


$ cd ~
$ cd android-sdk-linux*
$ cd tools

Now you should be in the /home/username/android-sdk-linux_x86-1.6_r1/tools/ directory.

List the programs
$ ls -l

-rwxrwxrwx 1 moma moma  332723 2009-09-03 20:08 adb
-rwxrwxrwx 1 moma moma    3526 2009-09-03 20:08 android
-rwxrwxrwx 1 moma moma    2382 2009-09-03 20:08 apkbuilder
-rwxrwxrwx 1 moma moma    3514 2009-09-03 20:08 ddms
-rwxrwxrwx 1 moma moma   74379 2009-09-03 20:08 dmtracedump
-rwxrwxrwx 1 moma moma    1940 2009-09-03 20:08 draw9patch
-rwxrwxrwx 1 moma moma 5710146 2009-09-03 20:08 emulator
-rwxrwxrwx 1 moma moma    1987 2009-09-03 20:08 hierarchyviewer
-rwxrwxrwx 1 moma moma   23084 2009-09-03 20:08 hprof-conv
drwxrwx--- 4 moma moma    4096 2009-09-03 20:08 lib
-rwxrwxrwx 1 moma moma   16598 2009-09-03 20:08 mksdcard
-rw-rw---- 1 moma moma  169407 2009-09-03 20:08 NOTICE.txt
-rw-rw-rw- 1 moma moma      33 2009-09-03 20:08 source.properties
-rwxrwxrwx 1 moma moma 1250507 2009-09-03 20:08 sqlite3
-rwxrwxrwx 1 moma moma    3871 2009-09-03 20:08 traceview
-rwxrwxrwx 1 moma moma  185477 2009-09-03 20:08 zipalign

If you want to run a tool you have to cd into the tools/ directory first.
We decided not to complete the step 5) and the tools/
directory is not in the global $PATH.
I will show you some examples here.

Where are you now?
$ pwd
/home/moma/android-sdk-linux_x86-1.6_r1/tools

Working with the adb (Android Device Bridge) command.

See: http://developer.android.com/guide/developing/tools/adb.html

Let's first query all emulator instances. The port-number or name of the emulator is quite important here.
You have to prefix the command with ./  (it means the current directory).

$ ./adb devices
List of devices attached
emulator-5554   device       <-- notice the name and port number "
emulator-5554".
emulator-5556   device       <-- my second emulator instance.
HT98AL801622    device       <-- HTC Hero Android phone (real device).

If the listing is empty, start eg. your Hello Android application from the Eclipse.
You can have several emulators or real phones up and running at the same time.

Then remote-connect to the emulator instance or device.
You must know that the emulator is similar to a real Android-phone, they both run an
ARM CPU based Linux kernel.
This command will connect to the emulator instance and start a remote shell.
$ ./adb -s emulator-5554 shell

See picture 14b. 

You should see a shell (bash #) prompt.
You are logged in as the "root" admin user. Be careful beacuse it has all rights.
...

<TODO>

Simulate phone calls and send SMS

Read: http://developer.android.com/guide/developing/tools/emulator.html#console

<TODO>
--

Hacking Android's data with sqlite3

See: http://developer.android.com/guide/developing/tools/adb.html#sqlite

Android phones contain a sqlite3 database engine. It's very fast and easy to use.
All programs can create their own databases in addition to the Android's pre-installed datafiles such as
contacts.db, mmssms.db and telephony.db.

You must remote connect to the Android emulator or device to examine the databases.
I repeat the basic commands here.
$ cd $HOME/android-sdk-linux_x86-1.6_r1/tools/
$ ./adb -s emulator-5554 shell

You are now connected to the device and command prompt # appears.
The /data/data/ directory contains the names of all
packages
and their sqlite3 databases.
Cd into the /data/data/ directory.
# cd /data/data

# pwd
/data/data

List all package names
first.
# ls -l

List all database files (*/databases/*.db)
# ls -l */*/*db

I also used this command to find the *.db files.
#
for i in *; do echo $i; ls -l $i/databases/; done

(I have edited the output a bit)

/data/data/com.android.alarmclock/databases/
-rw-rw---- app_0    app_0        4096 2009-08-26 13:06 alarms.db

/data/data/com.android.launcher/databases/
-rw-rw---- app_3    app_3        4096 2009-08-26 13:06 launcher.db

/data/data/com.android.providers.contacts/databases/
-rw-rw---- app_3    app_3       54272 2009-08-26 17:49 contacts.db

/data/data/com.android.providers.downloads/databases/
-rw-rw---- app_4    app_4        5120 2009-08-26 13:06 downloads.db

/data/data/com.android.providers.media/databases/
-rw-rw---- app_4    app_4       29696 2009-08-26 17:56 external-13031c18.db
-rw-rw---- app_4    app_4       23552 2009-08-26 13:06 internal.db

/data/data/com.android.providers.settings/databases/
-rw-rw---- system   system      19456 2009-08-26 18:39 settings.db

/data/data/com.android.providers.telephony/databases/
-rw-rw---- radio    radio       30720 2009-08-26 13:06 mmssms.db
-rw-rw---- radio    radio        9216 2009-08-26 17:56 telephony.db

/data/data/com.android.providers.userdictionary/databases/
-rw-rw---- app_3    app_3        4096 2009-08-26 13:06 user_dict.db
---

Now let's study some data.

While in the /data/data/ directory, start the sqlite3 database manager with
contacts.db database as argument.
As you already understand, we are running the sqlite3 command in (inside) the emulator or phone device.

# sqlite3 com.android.providers.contacts/databases/contacts.db
SQLite version 3.5.9
Enter ".help" for instructions
sqlite>

Try the "help" command first (note the dot).
sqlite> .help
...

List all tables in the contacts.db database.
sqlite> .tables
_deleted_groups      contact_methods     peopleLookup
_deleted_people      extensions               phones               
_sync_state              groupmembership    photos               
_sync_state_metadata    groups              settings             
android_metadata     organizations          voice_dialer_timestamp  calls   people

Retrieve all rows from the people table.
You may first add some entries to the emulator's/phone's contacts list. Terminate the SQL command with ";".
sqlite> select * from people;
...

Print schema
sqlite> .schema people
...

And finally quit the sqlite3 manager.
sqlite> .quit
--

Press cntr + d or type exit to terminate the remote (shell) connection.



Starting with Java programming
http://java.sun.com/docs/books/tutorial

Android SDK 1.6 demonstration and motivation videos
http://www.youtube.com/MBRFkLKRwF...
http://www.youtube.com/I6ObTqIiYfE...

Other important guides
http://developer.android.com/guide/

This is especially for newbies
http://developer.android.com/guide/developing/eclipse-adt.html

Designing activities (programs)
http://developer.android.com/guide/practices/ui_guidelines/activity_task_design.html

Porting OpenGL to Android
http://insanitydesign.com/wp/projects/nehe-android-ports/


Android applications
http://en.androidwiki.com/wiki/Applications

Android beginners' and developers' mailing lists

http://groups.google.com/group/android-beginners
http://groups.google.com/group/android-developers

Samples
http://wiki.andmob.org/samplecode

New: Compile c-program on Ubuntu, run it on Android
http://simos.info/blog/archives/1185

-- the end --



Return to http://www.futuredesktop.org


Sample 1:
http://www.androiddevelopment.org/category/code-examples/
http://developer.android.com/resources/tutorials/views/index.html

http://code.google.com/p/android-examples/


If you see this essage
Android requires compiler compliance level 5.0 or 6.0. Found '1.4' instead. Please use Android Tools > Fix Project Properties.
Select your project name in the left panel. Then select Project -> Properties -> Java Compiler from the menu.
Set the JDK compliance to 1.6 or newer. And [Apply] the settings.
The rec-compile/clean the project from Project -> Clean menu.