[英]Unable to write to the Internal Storage
請看下面的代碼
File folder = new File("/Main Note/Sub Notes/"+dateStr+"/");
File file = new File(folder+name.getText().toString()+".txt");
try
{
if(!folder.exists())
{
folder.mkdirs();
}
FileOutputStream outputStream = openFileOutput(file.getName(),Context.MODE_WORLD_WRITEABLE);
outputStream.write(spokenText.getBytes());
outputStream.flush();
outputStream.close();
Toast.makeText(VoiceNotes.this, "Data Successfully written to: "+file.getAbsolutePath(), Toast.LENGTH_LONG).show();
}
catch(IOException io)
{
Toast.makeText(VoiceNotes.this, "Error in Writing to SD", Toast.LENGTH_LONG).show();
}
在這里,我試圖將數據寫入內部存儲器。 這沒有錯誤,顯示數據已成功寫入。
但是當我導航到手機中的內部SD時,看不到它創建的任何文件夾或文件! 我想我做錯了什么,這是我第一次寫入Android的內部存儲。
File folder = new File(context.getFilesDir(),"/MyFolder/");
文件將在“ /data/data/app.package/files / ...”中創建。 但是只有在設備已植根的情況下,您才能看到它們
要訪問返回的路徑getExternalStorageDirectory()
所描述的在這里 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.