• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

How to detect SD card?  RSS feed

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.
Posts: 19810
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.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!