内部ストレージにテキスト ファイルを作成し、Bluetooth を介してペアリングされたデバイスとファイルを共有したいと考えています。
これどうやってするの?次のコードを試しましたが、機能しません
private void WriteFile(String text, Context context, String deviceAddress)
    {
        try {
            FileOutputStream fos = context.openFileOutput("command.txt", Context.MODE_WORLD_WRITEABLE);
            fos.write(text.getBytes());
            fos.flush();
            fos.close();
            File file = new File(context.getFilesDir(), "command.txt");
            if (file.exists())
               Toast.makeText(context, "command file created successfully", Toast.LENGTH_LONG).show();
            else
                Toast.makeText(context, "command file not created.", Toast.LENGTH_LONG).show();
            ContentValues values = new ContentValues();
            values.put(BluetoothShare.URI, "content://" + Uri.fromFile(file));
            values.put(BluetoothShare.DESTINATION, deviceAddress);
            values.put(BluetoothShare.DIRECTION, BluetoothShare.DIRECTION_OUTBOUND);
            Long ts = System.currentTimeMillis();
            values.put(BluetoothShare.TIMESTAMP, ts);
            context.getContentResolver().insert(BluetoothShare.CONTENT_URI, values);
            Toast.makeText(context, "Command sent successfully", Toast.LENGTH_LONG).show();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
File unknown, file not sent エラーが発生します。
何をすればよいでしょうか?
どんな助けでも感謝します。
ありがとう