For my project I want to be able to save sensor data to a file, and be able to access it from a PC for further analysis. This is the code I have so far and it works successf
Why, best not to send it to your mail. See the following example:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_EMAIL, new String[] {"email@example.com"});
intent.putExtra(Intent.EXTRA_SUBJECT, "subject here");
intent.putExtra(Intent.EXTRA_TEXT, "body text");
File root = Environment.getExternalStorageDirectory();
File file = new File(root, xmlFilename);
if (!file.exists() || !file.canRead()) {
Toast.makeText(this, "Attachment Error", Toast.LENGTH_SHORT).show();
finish();
return;
}
Uri uri = Uri.parse("file://" + file.getAbsolutePath());
intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(intent, "Send email..."));
Have you tried using a terminal with "adb pull filename" and the full pathname that Astro sees? That ought to work, and if you're using this yourself wouldn't be too hard.
I experienced this as well (on my Nexus 4). The file existed on my phone (found it using adb shell), but my file explorer on my laptop couldn't find the file. Like @billtian said, this seems to be a bug on Nexus 4 and 7 devices. I tried out my code on an old Ericsson Xperia and there I could locate the file via my laptop.