[問題] 讀檔/存檔
我用面的程式可以成功開啟 assets 資料夾底下的 txt 檔
InputStream is = getAssets().open("massage.txt");
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
massage = (TextView) findViewById(R.id.textView);
massage.setText(is.toString());
請問要怎麼反過來將資料儲存進去 assets 資料夾中?
並沒有類似 OutputStream is = getAssets().open("massage.txt"); 的語法
先謝謝大家了
--
我是麵T,哩賀
http://ppt.cc/-eS5
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.227.102.243
→
03/05 17:52, , 1F
03/05 17:52, 1F
→
03/05 17:53, , 2F
03/05 17:53, 2F
因為是新手,找了好久終於知道可以把檔案
massage.txt放在assets中,並可以編譯進去apk檔。
讀沒有問題了,現在就沒辦法寫入!(網路上有些文章說assets無法寫入)
機身內數據讀寫
FileInputStream fileInput = this.openFileInput("massage.txt")
這樣用 Android Studio 編譯時,我要把 massage.txt 放在哪個資料夾下?
(試過放在好多地方,但只有放在assets底下才會被打包進去apk檔)
才能使 apk 安裝好後 massage.txt 也被安裝到"那個"位置。
還是說 massage.txt 依然需要先放在 assets 中,首次執行時再複製到"那個"位置?
希望h大不吝指教
※ 編輯: noodleT 來自: 61.227.102.243 (03/05 18:22)
※ 編輯: noodleT 來自: 61.227.102.243 (03/05 18:23)
→
03/05 19:48, , 3F
03/05 19:48, 3F