Skip to content Skip to sidebar Skip to footer

I Can't Make Sense Context.getfilestreampath Trying To Test Wether A File Path Exists?

I have tried to make sense of the getFileStreamPath madness for some hours now. Could someone please explain how to test if a path = 'shop/crates/fruits' exists? In an attempt to s

Solution 1:

Yeah, the crappy android APIs. The secret sauce is to use context.getFilesDir(). That's your file:

Filefile=newFile(context.getFilesDir() + File.separator + path);

After that, the file behaves normally.

Solution 2:

First, the getFileStreamPath returns the absolute path on the filesystem where a file created with openFileOutput(String, int) is stored.

Are you trying to test the internal or external storage's path? If you want to use external storage use getExternalFilesDir(). If you want to use internal package embedded resources like res/raw, it's another story:

Android how to get access to raw resources that i put in res folder?

But I don't think it will work the way you are presuming to get it.

Read this http://developer.android.com/guide/topics/data/data-storage.html carefully.

Read Using the Internal Storage chapter there.

Also see:

How to create a file on Android Internal Storage?

Read/write file to internal private storage

http://www.vogella.de/articles/AndroidFileSystem/article.html

Post a Comment for "I Can't Make Sense Context.getfilestreampath Trying To Test Wether A File Path Exists?"