2

This is for the first time i am using external storage in android. I need some help how can i perform different operations such as how to check whether External Storage is available or not?, How to write files or pictures into storage .

Akhil Jain
  • 13,872
  • 15
  • 57
  • 93
Rakesh Gondaliya
  • 1,050
  • 3
  • 25
  • 42

2 Answers2

3

To clarify the first part of CommonsWare's answer (I couldn't seem to add a comment to the comment stream): you want to check that...

Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);

... is true.

Adil Hussain
  • 30,049
  • 21
  • 112
  • 147
2

how to check whether External Storage is available or not?

Use Environment.getExternalStorageState().

How to write files or pictures into storage

Use standard Java I/O, working off a directory built using Environment.getExternalStorageDirectory().

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • 6
    If you write files, dont forget to set the permission in the Manifest. – ccheneson Aug 30 '10 at 07:07
  • thanks a lot.. I have used this already but i want to able to add files to media storage and then retrieve it back.. So any hints? U can even send some reference..Thanks – Rakesh Gondaliya Aug 30 '10 at 07:22
  • @rakesh-gondaliya: You ask a question, then say you "used this already". Why did you ask the question in the first place? – CommonsWare Aug 30 '10 at 07:37
  • sorry for that. Can u give me some hints to create app which will allow me to write files into External storage and then i will be able to read that. thanks – Rakesh Gondaliya Aug 30 '10 at 07:57
  • @rakesh-gondaliya: Use standard Java I/O, working off a directory built using `Environment.getExternalStorageDirectory()`. If you are unfamiliar with Java I/O, I suggest that you spend a month or two outside of Android learning Java. – CommonsWare Aug 30 '10 at 08:02