0

I have an Android application that generates some data (simple text file) that I would like to transfer to my PC for further processing. My understanding is that my storage options for a place to save such a file are a) internal storage or b) external storage. My device is a rooted Nexus 7 running Marshmallow, and I can't get either option to work.

With internal storage I'm able to write the file but then it's nowhere to be found using ADB or Eclipse DDMS. With external storage I'm getting FileNotFoundExceptions which I'm guessing are due to new complicated permissions, so none of Android saving file to external storage is working.

Is this possible and, if so, is there an easy way to do it?

Community
  • 1
  • 1
Mark Cramer
  • 2,614
  • 5
  • 33
  • 57

2 Answers2

0

What is your targetSdkVersion? If you target 22 and below, the new permission policy won't take effect.

Xiaoxi Zhang
  • 670
  • 1
  • 5
  • 7
  • Not sure why this got a downvote, but I just gave an upvote. I dropped my `targetSdkVersion` from 23 to 22 and... it appears to have worked! Now how do I get the file? The path = `/storage/emulated/0/file.txt`, but in DDMS I can open `storage` and then `emulated`, but there's nothing after that. – Mark Cramer May 16 '16 at 03:22
0

It is possible to write a text file in Android and read the same in your PC using external-storage. This app does the same. You can find a simple example here. If this does not work for you, kindly share your code-snippet that writes the file.

  • I tried a solution using `File file = new File(Environment.getExternalStorageDirectory(), FILE_NAME);` but got `FileNotFoundException` because, I believe, of Marshmallow permissions. I've installed your app. How do I get the files onto my PC? – Mark Cramer May 16 '16 at 02:50
  • I've tried your code, including the ` – Mark Cramer May 16 '16 at 03:07
  • 1
    I guess you are right regarding permissions in marshmallow. My app has Froyo as the minimum sdk. I find a similar explanation here http://stackoverflow.com/questions/33162152/storage-permission-error-in-marshmallow If you want to get the files to PC from my app, just create a few files/folders, open the external storage in your PC and look for the folder mycoin/editor. – John T. Jose May 16 '16 at 05:13
  • Android explains the change in marshmallow here https://developer.android.com/training/permissions/requesting.html – John T. Jose May 16 '16 at 05:34