Android 路径:“/SD卡/";适用于所有设备?

Android 路径:“/SD卡/";适用于所有设备?,android,android-sdcard,Android,Android Sdcard,我在我的应用程序中使用了此代码 它对所有设备都正常吗?它对所有设备都有效吗 String path= "/sdcard/.beta1/data/text/myfile.txt"; File myFile = new File(path); myFile.getParentFile().mkdirs(); myFile.createNewFile(); FileOutputStream fOut = new FileOutputStream(myFile); 我还尝试了Environment.g

我在我的应用程序中使用了此代码

它对所有设备都正常吗?它对所有设备都有效吗

String path= "/sdcard/.beta1/data/text/myfile.txt";
File myFile = new File(path);
myFile.getParentFile().mkdirs();
myFile.createNewFile();
FileOutputStream fOut = new FileOutputStream(myFile);
我还尝试了
Environment.getExternalStorageDirectory().getPath()
所有设备都可以吗?所有设备都可以吗

String path= "/sdcard/.beta1/data/text/myfile.txt";
File myFile = new File(path);
myFile.getParentFile().mkdirs();
myFile.createNewFile();
FileOutputStream fOut = new FileOutputStream(myFile);
不。它不仅不能在所有设备上工作,而且不能在所有设备的所有用户上工作。大多数安卓设备支持多用户;不同的用户将有不同的和路径从不硬编码路径

使用、或处理外部存储上的文件。前两种方法的优点是不需要API级别19或更高级别的任何权限

所有设备都可以吗?所有设备都可以吗

String path= "/sdcard/.beta1/data/text/myfile.txt";
File myFile = new File(path);
myFile.getParentFile().mkdirs();
myFile.createNewFile();
FileOutputStream fOut = new FileOutputStream(myFile);
不。它不仅不能在所有设备上工作,而且不能在所有设备的所有用户上工作。大多数安卓设备支持多用户;不同的用户将有不同的和路径从不硬编码路径

使用、或处理外部存储上的文件。前两种方法的优点是不需要API级别19或更高级别的任何权限

所有设备都可以吗?所有设备都可以吗

String path= "/sdcard/.beta1/data/text/myfile.txt";
File myFile = new File(path);
myFile.getParentFile().mkdirs();
myFile.createNewFile();
FileOutputStream fOut = new FileOutputStream(myFile);
不。它不仅不能在所有设备上工作,而且不能在所有设备的所有用户上工作。大多数安卓设备支持多用户;不同的用户将有不同的和路径从不硬编码路径

使用、或处理外部存储上的文件。前两种方法的优点是不需要API级别19或更高级别的任何权限

所有设备都可以吗?所有设备都可以吗

String path= "/sdcard/.beta1/data/text/myfile.txt";
File myFile = new File(path);
myFile.getParentFile().mkdirs();
myFile.createNewFile();
FileOutputStream fOut = new FileOutputStream(myFile);
不。它不仅不能在所有设备上工作,而且不能在所有设备的所有用户上工作。大多数安卓设备支持多用户;不同的用户将有不同的和路径从不硬编码路径

使用、或处理外部存储上的文件。前两种方法的优点是不需要API级别19或更高级别的任何权限。

要读取文件:

final File file = new File(Environment.getExternalStorageDirectory()
                          .getAbsolutePath(), filename);
文件名
它是一个
字符串
变量

或者您也可以使用:

File sdCardDirectory = new File(Environment.getExternalStorageDirectory() + File.separator + "MyFolder/" + "MyFile.txt");
要读取文件,请执行以下操作:

final File file = new File(Environment.getExternalStorageDirectory()
                          .getAbsolutePath(), filename);
文件名
它是一个
字符串
变量

或者您也可以使用:

File sdCardDirectory = new File(Environment.getExternalStorageDirectory() + File.separator + "MyFolder/" + "MyFile.txt");
要读取文件,请执行以下操作:

final File file = new File(Environment.getExternalStorageDirectory()
                          .getAbsolutePath(), filename);
文件名
它是一个
字符串
变量

或者您也可以使用:

File sdCardDirectory = new File(Environment.getExternalStorageDirectory() + File.separator + "MyFolder/" + "MyFile.txt");
要读取文件,请执行以下操作:

final File file = new File(Environment.getExternalStorageDirectory()
                          .getAbsolutePath(), filename);
文件名
它是一个
字符串
变量

或者您也可以使用:

File sdCardDirectory = new File(Environment.getExternalStorageDirectory() + File.separator + "MyFolder/" + "MyFile.txt");


使用
Environment.getExternalStorageDirectory().getPath(),我认为它更好…请告诉我如何使用它?在一些帖子中,我看到它有时返回内部存储的路径?当然,请查看我的回答使用
Environment.getExternalStorageDirectory().getPath(),我认为它更好…请告诉我如何使用它?在一些帖子中,我看到它有时返回内部存储的路径?当然,请查看我的回答使用
Environment.getExternalStorageDirectory().getPath(),我认为它更好…请告诉我如何使用它?在一些帖子中,我看到它有时返回内部存储的路径?当然,请查看我的回答使用
Environment.getExternalStorageDirectory().getPath(),我认为它更好…请告诉我如何使用它?在一些帖子中,我看到它有时返回内部存储的路径?当然,请检查我的回答OK谢谢,还有一个查询-'String path=Environment.getExternalStorageDirectory().getPath()+“/.beta/”;'与'path=“/sdcard/.beta/”;相同@阿玛:不要创建字符串。您需要一个
文件
。使用
File betaDir=new文件(Environment.getExternalStorageDirectory(),“.beta”)。好的,谢谢,再来一个查询-'String path=Environment.getExternalStorageDirectory().getPath()+“/.beta/”;'与'path=“/sdcard/.beta/”;相同@阿玛:不要创建字符串。您需要一个
文件
。使用
File betaDir=new文件(Environment.getExternalStorageDirectory(),“.beta”)。好的,谢谢,再来一个查询-'String path=Environment.getExternalStorageDirectory().getPath()+“/.beta/”;'与'path=“/sdcard/.beta/”;相同@阿玛:不要创建字符串。您需要一个
文件
。使用
File betaDir=new文件(Environment.getExternalStorageDirectory(),“.beta”)。好的,谢谢,再来一个查询-'String path=Environment.getExternalStorageDirectory().getPath()+“/.beta/”;'与'path=“/sdcard/.beta/”;相同@阿玛:不要创建字符串。您需要一个
文件
。使用
File betaDir=new文件(Environment.getExternalStorageDirectory(),“.beta”)