私は(emulator running AndroidとUbunutを実行しているホストシステム間)の共有フォルダ内のファイルを作成しようとしています:は/ mnt /共有/ androidSharedアンドロイド - オープンに失敗しました:中EACCES(パーミッション拒否)を/ mnt
を私は、権限の問題を持っていないし、私のマニフェストファイルに必要な行を追加しました:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.yalishanda.myapplication">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
しかし、私はこのerrosを取得するファイルを作成しようとしたとき:
java.io.FileNotFoundException:を/ mnt /共有/ androidSharedを/test.txt:オープンに失敗しました:EACCES(許可が拒否されました)
対応するコード:
public void onButtonTap(View v){
String filepath ="/mnt/shared/androidShared/test.txt";
FileOutputStream fos = null;
try {
FileOutputStream outputStream = new FileOutputStream (new File("/mnt/shared/androidShared/test.txt"));
byte[] buffer = "This will be writtent in test.txt".getBytes();
fos.write(buffer, 0, buffer.length);
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
は、私はまた、次のようにバックスラッシュをエスケープしてみました:
//mnt//shared//androidShared//test.txt"
しかし、エラーは同じです。
ファイルを作成できないのはなぜですか?ファイルをあらかじめ作成しておいても、同じエラーが発生します。この行が実行されたとき
例外がスローされます。
FileOutputStream outputStream = new FileOutputStream (new File("/mnt/shared/androidShared/test.txt"));
私は成功せず、同様にそれらのアプローチを試してみました:http://paste.ubuntu.com/25364833/
は、どのように私は、このフォルダ内のファイルを作成することができますか?
ありがとうございます!
"私は共有フォルダにファイルを作成しようとしています(Androidを実行するエミュレータとUbunutを実行するホストシステムの間):/ mnt/shared/androidShared" - どのように共有フォルダを作成しようとしていますか?私はこれが利用可能なオプションであることに気づいていません。 – CommonsWare
@CommonsWare私はフォルダではなく共有ファイルを意味しました。 – LandonZeKepitelOfGreytBritn
OK、どうやって共有ファイルを作成しようとしていますか?私はこれが利用可能なオプションであることに気づいていません。 – CommonsWare