Открыть открыть записанный файл (в Genymotion)?

SQLite, Preferences, файлы, SD, Content Provider, XML, JSON
Ответить
sharks_hockey
Сообщения: 6
Зарегистрирован: 07 июн 2016, 18:07

Открыть открыть записанный файл (в Genymotion)?

Сообщение sharks_hockey » 11 июн 2016, 15:34

Такой код. Как с компьютера найти 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]

Ответить