Thursday 15 July 2010

android - Best practice for handling writing to external sd card? -



android - Best practice for handling writing to external sd card? -

my app allows users browse file scheme select location save file. unfortunately, 4.4 users no longer able save external sd cards. workarounds i've found online couched beingness "not particularly ideas", other applications succesfully saving external sd cards, assume these workarounds in use.

is there safe/smart workaround or recommended best practice dealing issue?

some code throws exception on 4.4.2 device:

public class sdsample extends activity { public void oncreate(bundle bundle) { super.oncreate(bundle); file external = new file("/storage/extsdcard/dcim/"); file textfile = new file(external, "textfile.txt"); seek { textfile.createnewfile(); fileoutputstream fos = new fileoutputstream(textfile); fos.write("hello".getbytes()); fos.close(); } grab (exception e) { //java.io.ioexception: open failed: eacces (permission denied) log.e("", log.getstacktracestring(e)); } } }

afaik there mediafile hack uses media content provider. not work on devices. e.g. here failed on samsung galaxy note3 neo. here found mediafile hack: http://forum.xda-developers.com/showthread.php?t=2634840

the official way solve problem storage access framework: http://developer.android.com/guide/topics/providers/document-provider.html

on android 4.4, works single files user has select. @ to the lowest degree have total access file, in info directories of other apps (on sd). far understood, it's not possible e.g. allow user take 1 directory , have total access in future.

this should come action_open_document_tree, it's api21. , i'm eger have lollipop on device sd slot, not test yet ;-) here moto g or lg g3? :) http://developer.android.com/reference/android/content/intent.html#action_open_document_tree

android

No comments:

Post a Comment