Страница 1 из 1

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

Добавлено: 11 июн 2016, 15:34
sharks_hockey
Такой код. Как с компьютера найти 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]