Android Question ExternalStorage: full file path?

mjcoon

Well-Known Member
Licensed User
In the original screen-shot of a file listing (link below), the full path of the containing folder is shown at the top of the list as a heading. Also an entry reading ".." with the standard meaning of "parent" to traverse upwards.

But when I run the demo it only shows "root", however far down the sub-folder hierarchy it really is. And no "..". To identify a file uniquely I need the full path and the device identity (SD card, USB or built-in). Is the screen-shot from the current version; or how do I find the information I need?

Mike.

externalstorage...
 

DonManfred

Expert
Licensed User
Longtime User
There is no such thing as a complete path when using the external storage class.
At least i do not know it.
 
Upvote 0

mjcoon

Well-Known Member
Licensed User
OK, perhaps if I explain my "use case" it would make my problem clearer.

But before I go that far, what about my fundamental question: why do I never see a multi-element heading to the file listing like the "Root / CANON_SC / DOCUMENT / 0001" that shows up in the screen-shot? Can anyone get a screen-shot like that with the current demo source?

Mike.
 
Upvote 0

Albert Kallal

Active Member
Licensed User
Thanks Manfred, but in that case how does it appear in the example externalstorage code screenshot? Has it been Photoshopped in? ;-)

Mike.

You still being fooled! The screen shot shows "root", but it NOT really the case, and the folder is NOT named root!

The fact that a folder was selected could have been:

//1/extstoreage/DCIM/stuff/a/b/c/Holiday2010/pictures/summer/

So lets say from above, we select Holiday2010 Then you going to get this:

root/Holiday2010/pictures/summer/

So, what is being said here?
If you browse though a HUGE file hierarchy and even down several folders deep?

Whatever folder you select will ALWAYS start at what you select. (and that sample code thus "assumes" your root starting point is root!

So in that screen shot, we don't even know if the person selected 5 folders deep or 10.

So, the actual file path folder you select could be a real huge long nasty folder way way deep done in a huge list of sub folders.

From YOUR software point of view?
It starts out at root, and if you ask for the path name, it will start out with root/then folder/then folder/

As a result, you always start out with root - even if its buried several folders deep. And SINCE from YOUR point of view an YOUR software? Well, it going to always start out with root regardless of where you actually started from, and what folder you selected. As a result, then you can't really get the actual path name, but only something that starts out with root. You have no idea if you actually buried 10 folders deep, but ONLY that the path name always starts with root/the next folder deep.

It is one of those "abstractions" in software. Part of this is good. (your code only ever has to deal with simple starting point called "root", and you thus just write your software to work that way).
This is the good part - you don't care where in that huge folder mess you are, and you actually don't have to care

The bad part is that you really never know what the actual FULL PATH location was selected! This forces you to write software that don't have to care about this issue.

If you need to actually "know" that actual location, then you are out of luck.

So, the screen shot is fooling you, since while the starting folder is "root", it not really root at all, and there is NOT even a folder named root!
root = the folder you selected!

You ONLY know from that selected point onwards. I sometime wonder if "root" is the best choice here for something that is not really the root. However, from your software's point of view? Root is always the starting point, and thus your software will always work assuming this idea, no matter what the folder the user actually selects. So, this can ease software development - since you always can assume you start out with that folder name.

Like on windows? Well, we "usually" assume that everything starts out on drive c:\ This is ALSO why some software if installed on drive D: will actually fail! (the developer made assumptions about the file path names and locations).

Some systems actually don't use drive letters, but some kind of "device" name. Anyway, the idea here is the actual path name should not matter nor effect how your software works. From your point of view - its just a folder. The other reason of course is the crack-down on security. On older versions of software, you could jump around and mess with darn near any folder. So, you download my app and I going to grab your contact list, or look for some folder called banking and steal all that information. So, now, they are tending to limit what folder(s) you can see + use - even those on a SD card.

So, you have to see the SD card as more as some kind of thing or device as compared to a hodge podge of folders that we all are OH SO VERY used to say due to our time spent on windows.

So, when we say you can't really get the path name? No, you can only get what the user LET you select from those folders, and it comes back as some kind of folder "thing" you selected, but it still some "thing" as opposed to a full path name.

Regards,
Albert D Kallal
Edmonton, Alberta, Canada.
 
Upvote 0

Shelby

Well-Known Member
Licensed User
Longtime User
Thank you, Albert, for adding some clarity to that mystery about roots.
 
Last edited:
Upvote 0

mjcoon

Well-Known Member
Licensed User
I'm still plugging away. And have now got (my version of) the demo example code to display a path as the pick-list heading, as shown in the screen-shot, and an ".." entry for choosing to return to parent.

Also I have searched back in the Basic4PPC forum for the program that I wrote way back, that in effect I am now trying to port to Android using B4A. It is in my post music-player-with-play-list

Mike.
 
Upvote 0
Top