Android studioを用いてAndroidアプリケーションを作成しているのですが,
アプリ内でcsvファイルを作成し,それを外部のPCから
Android端末にアクセスし,ファイルを閲覧,コピーしたいと考えております.
csvファイルを作成することはできたのですが,外部のPCから読み取ることができずに困っております.
端末内のファイルマネージャーからアクセスすれば,作成したファイルを見ることができるのですが・・・.
###該当のソースコード
private void setUpReadWriteExternalStorage() {
// 現在ストレージが書き込みできるかチェック
if (isExternalStorageWritable()) {
String str = "test"+","+"\n";
String filePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath()
+ "/csvfile/" + fileName;
//Log.d("debug", filePath);
File file = new File(filePath); file.getParentFile().mkdir(); FileOutputStream fileOutputStream; try { fileOutputStream = new FileOutputStream(file, true); OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, "UTF-8"); BufferedWriter bw = new BufferedWriter(outputStreamWriter); bw.write(str); bw.flush(); bw.close(); toast("保存に成功"); } catch (Exception e) { toast("保存に失敗"); e.printStackTrace(); } }
使用している端末は Xperia XZ Premium(SO-04J)です.
よろしくお願いします.
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/08/31 01:33
2017/08/31 04:27