Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9082011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:27:17+00:00 2026-06-16T20:27:17+00:00

I have a weird problem with my android File.exists functionality. Below is my code

  • 0

I have a weird problem with my android File.exists functionality. Below is my code

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
        super.onCreateView(inflater, container, savedInstanceState);
        View view = inflater.inflate(R.layout.fragment_file_browser, container);

        DataBaseHelper tmpHelper = new DataBaseHelper(getActivity());
        ButtonInfoContainer infoContainer = tmpHelper.getVideoWithId(videoId);



        //Tmp way to use this. When UX is finished will create a better way.
        File f = new File(Environment.getExternalStorageDirectory() + "/aslkfj");
        Log.i(StaticValues.TAG, Environment.getExternalStorageDirectory() + "/aslkfj");

        LinearLayout tmpView2 = (LinearLayout) view.findViewById(R.id.custom_recordings);
        if(f.exists());
        {
            Log.i(StaticValues.TAG, "f exists");

            String[] tmp = f.list();
            View tmpView = null;

            if(tmp != null)
            {
                for(int i = 0; i < tmp.length; i ++)
                {   
                    tmpView = inflater.inflate(R.layout.list_item, null);
                    TextView tmpText = (TextView) tmpView.findViewById(R.id.product_name);
                    tmpText.setText(tmp[i]);
                    tmpView2.addView(tmpView);
                }
            }
        }
        return view;
    }

Everything is cool but the weird part is that File.exists returns a false positive for me. It always says that the file exists (just in this app though). the path given above /aslkfj does not exist but when I run this code my logcat outputs f exists. Why would something like that happen.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T20:27:19+00:00Added an answer on June 16, 2026 at 8:27 pm

    You have a semi-colon at the end of your if condition: –

    if(f.exists());  <-- Semi-colon here is causing problem
    

    Due to this, the following block is just a local block, which will be executed regardless of what your if condition evaluate to.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have weird problem with this code: if I run it like shown below
I published my first app to the Android Market an have the weird problem,
I have a very weird problem I am writing a code that gets data
I have a weird problem with the Android emulator. I have created a virtual
I have a weird problem in the setup of my Android application which is
I have a weird problem: Implementing an interface to a webserver in my Android
I have a weird problem. While running my Android application, I receive Exception: java.lang.ClassCastException:
I have weird problem with this code $('img').hover(function(){ var $cap = $(this).parent().find('.cap'); window.setTimeout(function(){$cap.stop(true,false).animate({bottom:164},500)},500); },function(){
I have the following weird problem. My main activity looks like this: public class
I am facing a weird problem regarding bluetooth on android devices. I have one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.