i want move images stored in assets folder sd card....
private void copyassets() { assetmanager assetmanager = getassets(); string[] files = null; try { files = assetmanager.list(""); } catch (ioexception e) { log.e("tag", "failed asset file list.", e); } for(string filename : files) { inputstream in = null; outputstream out = null; try { in = assetmanager.open(filename); file outfile = new file(getexternalfilesdir(null), filename); out = new fileoutputstream(outfile); copyfile(in, out); in.close(); in = null; out.flush(); out.close(); out = null; } catch(ioexception e) { log.e("tag", "failed copy asset file: " + filename, e); } } } private void copyfile(inputstream in, outputstream out) throws ioexception { byte[] buffer = new byte[1024]; int read; while((read = in.read(buffer)) != -1){ out.write(buffer, 0, read); } }
this standard code i've used, , have made changes in manifest for
<uses-permission android:name="android.permission.write_external_storage"/>
i have called above function in oncreate method of java class i'm not getting option of "move sd card" in manage applications, nor files getting copied .
instead showing error : 07-11 16:59:29.042: e/tag(4997): java.io.filenotfoundexception: images
Comments
Post a Comment