Такой код. Как с компьютера найти my_file.txt?
[syntax=java]String baseFolder;
if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
baseFolder = mContext.getExternalFilesDir(null).getAbsolutePath();
Log.d("debug", "base folder one" + baseFolder);
}
else {
baseFolder = mContext.getFilesDir().getAbsolutePath();
Log.d("debug", "base folder two" + baseFolder);
}
String string = "hello world!";
Log.d("debug", "base folder" + baseFolder);
File file = new File(baseFolder + "my_file.txt");
FileOutputStream fos = new FileOutputStream(file);
try {
fos.write(string.getBytes());
fos.close();
} catch (IOException e) {
e.printStackTrace();
}[/syntax]
Открыть открыть записанный файл (в Genymotion)?
-
- Сообщения: 6
- Зарегистрирован: 07 июн 2016, 18:07