2011-08-28 33 views
1

我試圖在sdcard文件夾下創建路徑「/ package name/databases」。任何人都有祕密?有誰知道如何在Eclipse DDMS文件資源管理器中創建文件夾樹?

+0

爲什麼存儲應用程序的數據庫文件(* .db的)之外,以它的原始路徑(data/data/APPLICATION_PACKAGE/databases/DATABASE_NAME.db)? –

+0

@Vegolath - 幾個可能的原因。它可能很大。此外,如果它位於應用程序的私有存儲區域,DDMS將無法訪問它(除了在仿真器或根設備上) –

+0

@Chris Stratton,請儘量避免隨應用程序一起傳輸繁重的數據庫。如果可以的話,嘗試在服務器上遠程訪問數據庫,然後使用您的應用訪問它,例如REST應用。 –

回答

1

您是否在使用fileobj.mkdir()方法從File類?檢查該目錄是否存在,如果不存在則創建它。 Refer

不要忘記寫入外部存儲的權限,WRITE_EXTERNAL_STORAGE

+0

感謝您提醒我有關權限。這與此無關,但會在後續活動中使用。 [請參閱上面的評論] – gssi

1

只需選擇父文件夾,然後單擊小號+(「新建文件夾」)。對於下一個子文件夾再次執行此操作。

enter image description here

+0

請注意:我試圖在模擬器中執行此操作,而不是實際的手機!我的SD卡文件夾在mnt下。它似乎不允許任何添加... – gssi

+0

無法重現。你真的添加了一個SD卡到你的模擬器?默認情況下,卡片大小字段爲空,導致沒有SD卡(在這種情況下,狀態欄中應該有一個通知)。文件資源管理器在這種情況下顯示一個sdcard文件夾,但是如果我嘗試在那裏創建一些東西,我會得到一個只讀消息。但是,如果我爲卡添加了一些空間,它適用於1.6 AVD和2.3.3。 – 2011-08-28 18:37:06

+0

我不記得以前向這棵樹添加任何東西。我在2.2 API8下運行。當我檢查AVD中的設置時,sdcard存儲的大小爲31.49mb! – gssi

0

創建SD卡

Access to your Android SDK Tools folder and use command 「mksdcard」 in order to create one. 

By default installation on Windows, the Tools folder should be here: 

    C:\Program Files\Android\android-sdk\tools 
Using following syntax to create your desired SD Card 

    mksdcard [memory size] [output file] 

For example, I’d like to create a SD card with 200 MB in memory and put the files in 
C:\Personel\AndroidNewbie\SDCard with file named 「sdcard_dev.iso「, I do like this: 

mksdcard 256M C:\Personel\AndroidNewbie\SDCard\<span class="skimlinks-unlinked">sdcard_dev.iso</span> 

然後

使用SD卡

You’ve done creating your desired SD Card, now you need it to be used by Android emulator. Open Eclipse, 
    access to your project. 
    On menu Run -> Run Configurations, click on Android Configuration on the left tree menu, click on tab 
    Target on the right pane. You will see at the bottom: 「Additional Emulator Commandline Options」 and an 
    Input/Edit box below: 
Just type your input sdcard following syntax 
    -sdcard [sdcard location] 

For example, with the SD Card I’ve created above, I type: 

-sdcard C:\Personel\AndroidNewbie\SDCard\<span class="skimlinks-unlinked">sdcard_dev.iso</span> 
相關問題