Hello,

I'm a beginner in Android and request any help on the following.

I'm trying to use an SDCard loaded on to the Emulator and store files
programmatically.

The code snippet is as below

public class Downloader {
public Downloader(String path) {
this.path=sanitize(path);
Log.d("DEBUG","The File Path is " + path);
}


public String sanitize(String path) {
if (!path.startsWith("/")) {
path = "/" + path;
}

return Environment.getExternalStorageDirectory().getAbsolutePath()
+path;
}

public void start() throws IOException {
// Check if Media is mounted else throw IOException
String state = Environment.getExternalStorageState();
if(state != Environment.MEDIA_MOUNTED) {
Log.d("DEBUG", "The Card is Not Mounted " + state +"--");
throw new IOException ("SD Card is not Mounted. It is in " + state);
}

}

With the above code I'm able to see the "The Card is Not Mounted --"
message in the logcat. I'm making use of the following permissions in
the manifest.xml

<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

Questions
1. Are there additional permissions to be included?
2. The Downloader.java is a helper class whose object is being used in
a Receiver. Does giving the receiver the WRITE_EXTERNAL_STORAGE would
also enable Downloader.java to access the SDCard
3. Any other suggestions

Best Regards
Acer

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to