Bug 11442 - Reading from Nexus simulated SD Card looks broken
Summary: Reading from Nexus simulated SD Card looks broken
Alias: None
Product: Android
Classification: Xamarin
Component: Pre-release ()
Version: 4.7.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: 4.8 (async)
Assignee: Jonathan Pryor
Depends on:
Reported: 2013-03-27 06:06 UTC by Paul Johnson
Modified: 2013-07-24 02:38 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Paul Johnson 2013-03-27 06:06:40 UTC

Using 4.7.2 alpha.

I am trying to read from the simulated SD card on my Nexus and I'm always hitting a file not found. The exact same code worked in 4.7.1 as well as previous versions so the permissions are fine as should be the code.

I'm doing this

path = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads).ToString(); 
string localPath = Path.Combine(path, "Affiliations.xml");
            if (!File.Exists(localPath))
                GeneralUtils.Alert(context, Resource.String.missingTitle, Resource.String.missingaff);
                return toReturn;

Both path and localPath are giving a result and the files being looked for are in the Downloads directory.
Comment 1 Jonathan Pryor 2013-05-03 10:57:52 UTC
Unable to reproduce using the unreleased 4.7.5 series:

	var path = Android.OS.Environment.GetExternalStoragePublicDirectory(
	string localPath = Path.Combine(path, "Affiliations.xml");
	Console.WriteLine ("# Test11442: localPath='{0}' Exists? {1}",
			localPath, File.Exists (localPath));

When I initially run the above, it fails (as expected):

> I/mono-stdout( 5937): # Test11442: localPath='/storage/emulated/0/Download/Affiliations.xml' Exists? False

If I then open the Android File Transfer utility and add an Affiliations.xml to the Download folder, it works:

> I/mono-stdout( 7158): # Test11442: localPath='/storage/emulated/0/Download/Affiliations.xml' Exists? True

I'm testing on a Nexus 10.
Comment 2 Paul Johnson 2013-05-03 11:22:41 UTC
Comment 3 narayanp 2013-07-16 09:12:33 UTC
I'm trying to verify this bug, but I'm not sure of the steps. Is there a small sample or test case you could provide that demonstrates the issue?
Comment 4 Jonathan Pryor 2013-07-16 09:27:13 UTC
@narayanp: My testcase from Comment #1 was:

1. Create a new (default) Android Application project.
2. Add a `using System.IO;` statement to the top of the file.
3. Add the code from Comment #1 into OnCreate().
4. Run the app.
5. Read `adb logcat`; it should print a message stating that Affiliations.xml doesn't exist.
6. Open the Android File Transfer utility (assuming OS X; not sure about Windows)
7. Within the Android File Transfer utility, open the Downloads folder.
8. Add a file there (drag & drop from "elsewhere").
9. Run the app.
10. Read `adb logcat`; it should now state that Affiliations.xml exists.
Comment 5 narayanp 2013-07-17 09:08:36 UTC
Today I have checked this issue with following builds:

X.S 4.0.10(build 5)
Mono 3.1.2
Xamarin.Android 4.8.0-8

We have followed the same steps as mentioned in Comment#4 and observed that when we debug or run the application we are getting "Affiliations.xml' Exists? False" as shown in gist: https://gist.github.com/atin360/a4720b1524279140a2fa

After that when we install Android File transfer utility it is showing "Could not connect to device, Try reconnecting or restarting your device"

Please suggest for the same
Comment 6 Jonathan Pryor 2013-07-17 09:17:13 UTC
@narayanp: Do you have Kies installed? It's apparently incompatible with the Android File Transfer utility: http://forums.androidcentral.com/t-galaxy-note-2/226590-android-file-transfer-not-working.html

I also don't know if you're on Windows or OS X; presumably that will change things.
Comment 7 narayanp 2013-07-23 04:35:44 UTC
Today I have checked this issue on following builds:

Mac Mountain lion
X.S 4.0.10(build 7)
Mono 3.1.2
Xamarin.Android 4.8.0-13

Motorloa RAZAR version 4.1.2

and followed the steps mentioned in comment#4 and observed that we are getting "Affiliations.xml' Exists? False" in adb logcat in both the cases after running the application(without dragging file into Downloads folder and after dragging file in downloads folder). This is the gist of logcat: https://gist.github.com/atin360/ec75a4f87764cb241931

Note: I have dragged the image file into Downloads folder.

Please let us know is that correct behavior?
Comment 8 Jonathan Pryor 2013-07-23 11:31:03 UTC
That is not correct behavior, in that Affiliations.xml is not found (Comment #4 step 10 is not satisfied).

> Note: I have dragged the image file into Downloads folder.

What is "the image file"?

Addendum to Comment #4 step 8: the file added to the Downloads folder must be named "Affiliations.xml" (case sensitive).

DId you add an Affiliations.xml file to the Downloads folder?
Comment 9 narayanp 2013-07-24 02:38:32 UTC
Today we have checked this issue again after adding Affiliations.xml file in Android File Transfer Utility. Now we are getting "Affiliations.xml' Exists? True". This is the gist for the same: https://gist.github.com/atin360/ec407003108719ee41aa

Mac Mountain lion
X.S 4.0.10(build 7)
Mono 3.1.2
Xamarin.Android 4.8.0-13

Motorloa RAZAR version 4.1.2

Changing the status to Verified.