android - getExternalStorageState() showing 'mounted' but still unable to create folder -
manifest has
<uses-permission android:name="android.permission.write_external_storage">
application settings, 'storage' = modify/delete sd card contents' same results on samsung tablet running 2.3.5 , motorola droid running 2.3.4. devices not tethered development machine.
code follows:
public class outputstudentrecords extends stactivity{ sharedpreferences mstudentsettings; protected cursor mcursor; boolean mexternalstorageavailable = false; boolean mexternalstoragewriteable = false; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.create_csv); string state = environment.getexternalstoragestate(); toast.maketext(getapplicationcontext(),"state " + state, toast.length_long).show(); if (!environment.media_mounted.equals(state)){ //we can read , write media mexternalstorageavailable = mexternalstoragewriteable = true; toast.maketext(getapplicationcontext(), "we can read , write ", toast.length_long).show(); file file = new file(environment.getexternalstoragedirectory() +file.separator +"studentrecords"); //folder name file.mkdir(); } else if (environment.media_mounted_read_only.equals(state)){ mexternalstorageavailable = true; mexternalstoragewriteable = false; toast.maketext(getapplicationcontext(), "we can read not write ", toast.length_long).show(); }else{ //something else wrong mexternalstorageavailable = mexternalstoragewriteable = false; toast.maketext(getapplicationcontext(), "we can't read or write ", toast.length_long).show(); } } }
toast returns state="mounted" skips down "we can't read or write" on both machines. i've missed can't find it, appreciated.
thank you
maybe should change this:
if (!environment.media_mounted.equals(state)){
into this:
if (environment.media_mounted.equals(state)){
(ie: remove "!")
Comments
Post a Comment