0

Here's a question I had stumbled upon a few days ago.

The question is asking for how the method, "load(String path, int priority)" should be used, and what syntax the "path" variable should be like. Unfortunately, all the answers to that question gives incorrect answers. None of them mentions the use of the "load(String, int)" method, and none of them even answers what "path" should look like.

I'm unable to come up with a solution to this. Could anyone help out?

Community
  • 1
  • 1
tom_mai78101
  • 2,383
  • 2
  • 32
  • 59

1 Answers1

1

The path is just the path of the file in the android filesystem.

For example, If I drag/drop foo.mp3 to my android filesystem, it gets placed at /mnt/sdcard/foo.mp3 I would pass /mnt/sdcard/foo.mp3 to the load method.

The base path (/mnt/sdcard/ ) may vary from phone to phone, so you can query it with Environment.getExternalStorageDirectory().

As far as I know it's not to be used with resources, but rather just files in your filesystem.

Also, should probably include this note from Android docs, so that the "sdcard" is not confusing. My phone does not even have an external sdcard, but all the files in my android filesystem get placed in the /sdcard/ folder, I have no idea why.

Note: don't be confused by the word "external" here. This directory can better be thought as media/shared storage. It is a filesystem that can hold a relatively large amount of data and that is shared across all applications (does not enforce permissions). Traditionally this is an SD card, but it may also be implemented as built-in storage in a device that is distinct from the protected internal storage and can be mounted as a filesystem on a computer.

Tim
  • 35,413
  • 11
  • 95
  • 121
  • So, the "path" syntax starts off with anything that `Environment.getExternalStorageDirectory()` returns, and ends with the targeted file's name? – tom_mai78101 Sep 18 '12 at 16:02
  • If your file lies directly in the root of the external storage, then yes. If I put it inside some folder it would be `getExternalStorageDirectory() + "/myfolder/" + "foo.mp3"` @tom_mai78101 – Tim Sep 18 '12 at 16:03