Android 不同设备上蓝牙文件夹的不同路径

Android 不同设备上蓝牙文件夹的不同路径,android,bluetooth,Android,Bluetooth,我的应用程序需要将一些文件从bluetooth文件夹传输到我的应用程序创建的另一个文件夹。问题是bluetooth文件夹位于不同设备上的不同路径。在我的三星galaxy S3上,路径是/mnt/sdcard/Bluetooth,当我在三星galaxy S2上测试应用程序时,我甚至找不到蓝牙文件夹!我是否可以用Java编程搜索或获取bluetooth文件夹 这是我导航到三星S3上Bluetooth文件夹的代码: File sdCard = Environment.getExternalStorag

我的应用程序需要将一些文件从bluetooth文件夹传输到我的应用程序创建的另一个文件夹。问题是bluetooth文件夹位于不同设备上的不同路径。在我的
三星galaxy S3
上,路径是
/mnt/sdcard/Bluetooth
,当我在
三星galaxy S2上测试应用程序时,我甚至找不到蓝牙文件夹!我是否可以用Java编程搜索或获取bluetooth文件夹

这是我导航到三星S3上Bluetooth文件夹的代码:

File sdCard = Environment.getExternalStorageDirectory();
String bluetoothFile = sdCard.getAbsolutePath() + "/Bluetooth";
File bluetoothFolder = new File(bluetoothFile);
并使用此
get
方法获取我的bluetooth文件夹的路径

public File getBluetoothFolder() {
    return bluetoothFolder;
}

这仅适用于三星S3,但当我将应用程序上载到另一部手机时,这只会导致出现
NullPointerException
,因为bluetooth文件夹不在
/mnt/sdcard/bluetooth

上传您的代码以了解更多信息,请查看您使用的是哪款不同的手机?三星S3和S2+HTC Desire。这不要紧,因为应用程序应该在android 2.2及以上版本的所有手机上运行。不要使用getAbsolutePath()方法,而是尝试以下
String bluetoothFile=sdcard.getPath()+“/Bluetooth”参见此
http://stackoverflow.com/q/1099300/996493