Android 在智能手机上编写一个世界可读的文件';记忆

Android 在智能手机上编写一个世界可读的文件';记忆,android,storage,android-file,Android,Storage,Android File,我正试图访问一个由于我的应用程序而填充的文件。我将其存储在手机内存中,但不存储在应用程序的内部内存中 我的问题是,当我在PC上打开文件时(手机通过USB连接),文件不存在。但当我直接从智能手机打开它时,它是可用的,而不是空的 我需要此文件在我的计算机上可用 在我的舱单上: 我试过这样做: 也是这样: 另一种方式。。 其中一些解决方案有效,但只能在我的手机上使用,因此无法在世界范围内阅读,其他解决方案则不起作用 OutPutStreamWriter、FileWriter、BufferedWrite

我正试图访问一个由于我的应用程序而填充的文件。我将其存储在手机内存中,但不存储在应用程序的内部内存中

我的问题是,当我在PC上打开文件时(手机通过USB连接),文件不存在。但当我直接从智能手机打开它时,它是可用的,而不是空的

我需要此文件在我的计算机上可用

在我的舱单上: 我试过这样做: 也是这样: 另一种方式。。 其中一些解决方案有效,但只能在我的手机上使用,因此无法在世界范围内阅读,其他解决方案则不起作用

OutPutStreamWriter
FileWriter
BufferedWriter
FileOutputStream
PrintWriter
、。。。?我必须选择哪一个

如何创建公共文件以便直接从计算机访问它

谢谢你的帮助

试试这个:

String toWrite = "save me to disk";
File dir = new File(Environment.getExternalStorageDirectory(), INSTALLATION_DIRECTORY); 
if (!dir.exists()) {
    dir.mkdirs();
}
File file = new File(dir, INSTALLATION_FILE);
FileOutputStream out = new FileOutputStream(file );
out.write(toWrite.getBytes());
out.close();

也许是因为它在别的地方还开着?不,这不是问题所在不,它仍然不起作用。我的文件已创建,文本已写入手机,但当我尝试在PC上查看同一文件时,文件夹是空的…此方法已由我测试过,并且有效。所以问题可能出在电脑连接上。您是否使用ADB shell查看该文件?是的,我可以在Android Debug Monitor中查看该文件,但在我的文件资源管理器中看不到它。短搜索产生了这些结果,请尝试他们的建议:它适用于我:
context.sendBroadcast(新的Intent(Intent.ACTION\u MEDIA\u MOUNTED,Uri.parse(“file://“+”my\u path”))谢谢您抽出时间!
FileWriter outFile = new FileWriter(Environment.getExternalStoragePublicDirectory("my_app/data/file.txt");
PrintWriter out = new PrintWriter(outFile);
out.append("text");
out.flush();
out.close();
 File file = Environment.getExternalStoragePublicDirectory("my_app/data/file.txt");
 FileOutputStream outputStream = context.openFileOutput(file, Context.MODE_WORLD_READABLE);
 PrintStream printStream = new PrintStream(outputStream);
 printStream.println(text);
 printStream.close();
File file = Environment.getExternalStoragePublicDirectory("my_app/data/file.txt");
FileWriter outFile = new FileWriter(file);
BufferedWriter buf = new BufferedWriter(outFile);
buf.write("hey");
buf.close();
outFile.close();
String toWrite = "save me to disk";
File dir = new File(Environment.getExternalStorageDirectory(), INSTALLATION_DIRECTORY); 
if (!dir.exists()) {
    dir.mkdirs();
}
File file = new File(dir, INSTALLATION_FILE);
FileOutputStream out = new FileOutputStream(file );
out.write(toWrite.getBytes());
out.close();