java - Android app says the file does not exist but it does. I need to install it -


here code:

        string dir = getfilesdir().getabsolutepath();         file myfile = new file(dir+"/file.apk");          if (myfile.exists())         {             textview.settext("file exists.");         }         else         {             textview.settext("file not exist.");         } 

myfile.exists() false. not know why. file exists , located in directory.

when solve problem, i'll try this:

            intent intent = new intent(intent.action_install_package);             intent.setdata(uri.fromfile(myfile));             intent.putextra(intent.extra_not_unknown_source, true);             intent.setflags(intent.flag_activity_new_task);             startactivity(intent); 

can help? why not see file?

update:

it's strange. if use code:

            if (myfile.exists())             {                 textview.settext("it exists");             }             else             {                 textview.settext(myfile.getabsolutepath());             } 

, goes 'else' , shows path file 'does not exist'.

try using code:

    string dir = getfilesdir().getabsolutepath();     boolean fileexists = (new file(dir + "/file.apk")).isfile();      if (fileexists)     {         // file exists     }     else     {         // file not exist     } 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -