2011年4月13日 星期三

[Android] Simnulate insert SD Card Into Android Emulator

> Create a SD card image file.

cd <Android SDK Path>\tools
mksdcard 128M sdcard.img

> Start Emulator with SD card.

emulator -avd Dalvik_10 -sdcard sdcard.img   (Dalvik_10 is name of emulator)

you can see the SD card infomation as below.




















> Copy file into SD card

adb push WAA.pdf /sdcard  (WAD.pdf is file name)


> Copy file from SD card

adb pull /sdcard



> Remove file from SD card

adb shell
cd sdcard
rm WDA.pdf









> Further more, you can read the file by NDK.....
/** file open */
jstring Java_com_example_Play_openFile( JNIEnv* env, jobject thiz )
{
    // Open file from SD card
    FILE *outfile;
    char dir[40] = "/sdcard/WAD.pdf";
    if((outfile = fopen(dir ,  "r")) == NULL )
    {
        return (*env)->NewStringUTF(env, "NULL");
    }

    fclose(outfile);
    return (*env)->NewStringUTF(env, "DONE");
}

沒有留言:

張貼留言