2012年5月25日 星期五

Access files in Android Emulator

When using Titanium to write something into Android's ApplicationDataDirectory, say a db file, you will never locate it using Spotlight on mac.
because the file is saved in the Android emulator itself.

In order to check on the file, need to use Android's platform tool:
Android Debug Bridge, or adb

Here's the step:
1. add adb path to ~/.bash_profile (do it once so can skip this step next time)
adb path is located in {android_sdk_directory}/platform-tools

default sdk directory: ~/Documents/android-sdk-mac_x86/

2. launch Terminal, type command 
adb -e shell

3. ls will show list of folders.

4. application data is located in
/data/data/{app-id}/app_appdata
you may get this location by calling Titanium's File.getNativePath();

==================================
use adb in this way is actually invoke a client to interact with server (which is the development machine, i.e. our macbook) via the daemon (which is the emulator)

To list available devices/emulator that you can interact with, use
adb devices
If you wanna "talk" to / send command to specific emulator, use this
adb -s emulator-5560
Copying files to/from an emulator/device
To copy a file or directory from the emulator, use
adb pull

To copy a file or directory to the emulator, use
adb push

More on adb command: http://developer.android.com/guide/developing/tools/adb.html

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For easy access, create script to extract files from emulator:
~/getAndroidFiles.sh
file will be copied from emulator to ~/android/temp

沒有留言:

張貼留言