• 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 ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

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.
 
Bartender
Posts: 19668
92
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!