Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to detect SD card?

 
Hardik Trivedi
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,

I want to detect sd card in android emulator.Based on presence of SD card I want to take decision whether file should be stored in SD card or phone memory.

Can any one help me out in this.
 
Tim Holloway
Saloon Keeper
Posts: 18359
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Android is Linux-based. In Linus, all mounted filesystem devices are branches of the root filesystem tree. So if by "phone memory" you mean the internal filesystem RAM as opposed to the SD card RAM, it's a matter of where in the filesystem tree you store the data. If my unreliable memory is correct, my own phone's SD card is mounted at "/data".

So for that phone at least, the mere presence of anything under "/data" is an indicator. I don't know if the Android java.io.File implementation can report mountpoints (I'd have to RTFM to even make sure on standard Java!), but chances are that you could Runtime.exec() the "df" Linux utility if the sandbox permits you to.

Of course in my phone, the SD card is only accessible when the back cover is removed, so it's not something I pop in and out like I have on other devices.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic