我在网上查看了很多代码,但似乎都遇到了问题。
使用以下函数创建并保存文件:
private static String filename = "eulerY.txt" ;
private void saveData() {
FileOutputStream fos_FILE_eulerY = null;
String message = "hello";
try {
fos_FILE_eulerY = openFileOutput(filename , MODE_PRIVATE);
fos_FILE_eulerY.write(message.getBytes());
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fos_FILE_eulerY != null) {
try {
fos_FILE_eulerY.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
// export data
sendEmail ();
}
Run Code Online (Sandbox Code Playgroud)
但是,当运行下面的代码发送文件时,我不断遇到问题 ClipData.Item.getUri
并按照建议使用此链接“/sf/ask/3368225801/”中的所有答案-item-geturi”,打开 Gmail 时,显示“无法附加文件”
private void sendEmail (){
File filelocation = new …
Run Code Online (Sandbox Code Playgroud)