Java 在android内部存储器中写入文件后没有文件
无错误,数据在inputstream和outputstream中。 我不知道为什么在执行文件后找不到它。 似乎没有一个文件创建时没有错误。 我添加了所有权限 使用权限android:name=android.permission.READ\u外部存储 使用权限android:name=android.permission.WRITE\u外部存储 使用权限android:name=android.permission.READ\u INTERNAL\u存储 使用权限android:name=android.permission.WRITE\u内部存储 使用权限android:name=android.permission.WRITE\u USER\u字典 重现问题 要清楚地了解是否有其他原因导致文件无法创建,并假设您没有根目录,请尝试在SD卡外部存储中创建文件 如果没有根目录,则无法通过浏览查看文件。您可以改为使用代码读取文件并记录其内容,还可以记住在文件不存在的情况下捕获异常。这将帮助您知道它可能不是创建的Java 在android内部存储器中写入文件后没有文件,java,android,file-io,inputstream,outputstream,Java,Android,File Io,Inputstream,Outputstream,无错误,数据在inputstream和outputstream中。 我不知道为什么在执行文件后找不到它。 似乎没有一个文件创建时没有错误。 我添加了所有权限 使用权限android:name=android.permission.READ\u外部存储 使用权限android:name=android.permission.WRITE\u外部存储 使用权限android:name=android.permission.READ\u INTERNAL\u存储 使用权限android:name=an
你在哪里找你的档案?如果将其写入内部存储,则在文件管理器应用程序中不会看到它。除非你是rootedREAD_INTERNAL_STORAGE和WRITE_INTERNAL_STORAGE在Android中不作为权限存在。它们不起作用,应从清单中删除。
Bundle bundle = data.getExtras();
ArrayList<String> matches = bundle.getStringArrayList(RecognizerIntent.EXTRA_RESULTS);
// the recording uri is in getData:
Uri audioUri = data.getData();
ContentResolver contentResolver = getContentResolver();
try {
InputStream is = contentResolver.openInputStream(audioUri);
String filename = "testVoice01";
final byte[] buffer = new byte[1024];
int read;
try {
OutputStream output = openFileOutput(filename, Context.MODE_PRIVATE);
while ((read = is.read(buffer)) != -1)
{
output.write(buffer, 0, read);
Log.d("output", output.toString());
}
output.flush();
output.close();
is.close();
Log.d("fileName", filename.toString());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}