Accessing app-created file on PC via USB

grainydroid1

New Member
Licensed User
Longtime User
Sorry if this issues has been addressed, I could not find it through search. :sign0104:

I am developing code on a Nexus 7 (no external SD card). My application should write some data to a text file that can later be read on a Windows PC via USB for processing.

My code:
B4X:
Dim Writer As TextWriter
log(File.DirRootExternal)    '/storage/emulated/0
Writer.Initialize(File.OpenOutput(File.DirRootExternal, "Data.txt", True))   
Writer.WriteLine("data")
Writer.Close

On the Nexus, I can use "File Manager" app to find and read Data.txt saved in 5(!) different but identical locations:
B4X:
/storage/sdcard0
/storage/emulated/0
/storage/emulated/legacy
/mnt/sdcard
/sdcard

In Windows, with the Nexus set to "Portable Media Player" mode, I can see the same directory structure as contained in the above 5 directories, but Data.txt is not present. If I create a new folder in this directory on Windows, it is created in all 5 locations above.

So far, the only solutions I have found are:
1. e-mail the file
2. set Nexus as FTP
3. root Nexus and use a program such as "Android Commander"
These are not ideal for my application

Is what I'm trying to do possible?
 

rboeck

Well-Known Member
Licensed User
Longtime User
If you have full access to the pc, make an shared folder on the pc. The use the SMB library and you can write direct to the shared folders on pc.

Other possibilities: Dropbox oder Google Drive

Greetings
Reinhard Böck
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I think I can help you:
1. Power off the Nexus 7. Do not just turn it off. Power it off. Wait aboust 10 seconds, while your device is connected via USB to your PC. Turn it back on.
2. Open Windows Explorer on PC and look under Nexus7, then 'Internal Storage' . You should be able to see your file: data.txt
 
Last edited:
Upvote 0

Mahares

Expert
Licensed User
Longtime User
No I do not have an insight, but I remember something close to your issue happened with my Droid razr phone a while back. I messed with it for a while, until I figure it out using the same procedure. It is almost similar to a soft reboot.
 
Upvote 0

LeeM

Member
Licensed User
Longtime User
I think I can help you:
1. Power off the Nexus 7. Do not just turn it off. Power it off. Wait aboust 10 seconds, while your device is connected via USB to your PC. Turn it back on.
2. Open Windows Explorer on PC and look under Nexus7, then 'Internal Storage' . You should be able to see your file: data.txt
Just wanted to say thanks for this, thought I was doing something wrong when I couldn't see my files.
Looked through the forums for hours looking for an answer so was really glad to find this :)
 
Upvote 0
Top