Trying to read pdf file stored in res folder android -


here code given below..wenever try open dat activity shows target file doesnt exist..please me.....thanks in advance

public class mainactivityalgb extends activity {         @override         protected void oncreate(bundle savedinstancestate)         {             super.oncreate(savedinstancestate);             setcontentview(r.layout.activity_main_activity_algb);             copyreadassets();          }          private void copyreadassets()         {             assetmanager assetmanager = getassets();              inputstream in = null;             outputstream out = null;             file file = new file(getfilesdir(), "cure.pdf");             try             {                 in = assetmanager.open("cure.pdf");                 out = openfileoutput(file.getname(), context.mode_world_readable);                  copyfile(in, out);                 in.close();                 in = null;                 out.flush();                 out.close();                 out = null;             } catch (exception e)             {                 log.e("tag", e.getmessage());             }              intent intent = new intent(intent.action_view);             intent.setdataandtype(uri.parse("file://" + getfilesdir() + "/cure.pdf"), "application/pdf");              startactivity(intent);         }          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);             }         }      } 

as per understanding have stored file in res folder.i assume inside raw folder, if not move raw folder.then can file input stream as

inputstream = getresources().openrawresource(r.raw.yourfile); 

hope helps.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -