找到蓝牙收件箱
我们的应用程序需要从外部硬件设备推送某些文件后从蓝牙收件箱中获取这些文件。有没有办法以编程方式查找蓝牙文件夹位置?在 Galaxy 上,它是 /mnt/sdcard/bluetooth
,在 Desire 上,它似乎是 /mnt/sdcard/downloads/bluetooth
。
谢谢!
Our app needs to grab certain files from the Bluetooth inbox after they are pushed from an external hardware device. Is there a way to programmatically find the Bluetooth folder location? On the Galaxy it's /mnt/sdcard/bluetooth
, and on the Desire it seems to be /mnt/sdcard/downloads/bluetooth
.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,没有简单易行的方法可以通过 API 来完成此操作(尽管应该有!)有
两种可行的解决方案(取决于使用上下文;第一个似乎通常更好):
On启动时,您的应用程序会检查是否存在
SharedPreference
(例如)“bluetoothLocation”。如果找不到,应用程序将搜索 (a) FS 或 (b) 根目录为 /mnt/ 的 FS(可能 (b) 更好),直到找到满足以下条件的文件:name.equals("bluetooth")
和isDirectory()
。然后它会保存路径,然后就可以了。或者(根据上下文),您可以
greoermmvemoper190erjvw0j9e2.txt
)。然后,您的应用程序会搜索 FS,直到找到具有此共享硬编码名称的文件,并保存该位置。这些都远非完美,它们的可行性取决于您的环境。我想我会把它扔在那里。希望有帮助。
As far as I can tell, there's no simple and easy way to do this via the APIs (although there should be!)
Two solutions that could work (depending on the usage context; the first one seems generally better):
On start-up, you app checks if there's a
SharedPreference
(e.g.) "bluetoothLocation". If it doesn't find it, the app searches either (a) the FS or (b) the FS rooted at /mnt/ (probably (b) is better) until it finds a File such that:name.equals("bluetooth")
, andisDirectory()
.Then it saves the path, and there you go. Alternatively (depending on the context) you could,
greoermmvemoper190erjvw0j9e2.txt
). Then your app searches through the FS until it finds a file with this shared, hard-coded name, and saves that location.These are both far from perfect, and their viability depends on your context. I thought I'd throw it out there. Hope it helps.