This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • 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
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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: 20351
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 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.
Hey cool! They got a blimp! But I have a tiny ad:
Programmatically Create PDF Using Free Spire.PDF with Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!