java - File not found exception - when creating new file on sdcard in android -


in application, requirement need install .apk file assets folder, trying copy apk file assets folder sdcard, file not found exception. these following code:

string file_path = environment.getexternalstoragedirectory().getabsolutepath(); string file_name = "imagedownloading.apk";  assetmanager assetmanager = getassets(); try{    inputstream input = new bufferedinputstream(assetmanager.open(file_name));    file path = new file(file_path);      if(!path.exists()){        path.mkdirs()     }             file file = new file(path,file_name);               outputstream output = new fileoutputstream(file);  // here file not found exception error.   byte data[] = new byte[1024];   int count;    while ((count = input.read(data)) != -1) {      output.write(data, 0, count);     }   output.flush();   output.close();   input.close();     }    catch(filenotfoundexception e){   toast.maketext(mainactivity.this,"file not found exception " + e.getmessage(),               toast.length_short).show();      } 

i have spent lot of time did not find out solution.

do have permission set in manifest file?

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

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -