Save to External Storage - Samsung (GT-P6810)

Dallas Williams

Member
Licensed User
Longtime User
Samsung Galaxy 7.7"
Honeycomb 3.2

I've been attempting to copy a file from the Internal Storage to the External Storage without any luck. If anyone could shed some light on this it would be much appreciated.

Output Of Directory Locations:
B4X:
#File.DirInternal
/data/data/net.dancescorelive.adj/files

#File.DirRootExternal
/mnt/sdcard

#File.DirDefaultExternal
/mnt/sdcard/Android/data/net.dancescorelive.adj/files
 

parijs

Active Member
Licensed User
Longtime User
B4X:
File.Copy(File.DirAssets,"yourfile.db", File.DirRootExternal, "YourDir/yourfile.db")
 
Upvote 0

Dallas Williams

Member
Licensed User
Longtime User
B4X:
File.Copy(File.DirAssets,"yourfile.db", File.DirRootExternal, "YourDir/yourfile.db")

I have tried to implement this previously using the following
B4X:
Log(File.Exists(File.DirDefaultExternal, "RunOrder_Tablet.txt"))
File.Copy(File.DirDefaultExternal, "RunOrder_Tablet.txt", File.DirRootExternal, "Android/data/net.dancescorelive.adj/files/TEST.txt")

#File.Exists
True

#File.Copy
Does not error however writes to the internal directory, the file it writes is located at:

/Root/Android/data/net.dancescorelive.adj/files/TEST.txt
 
Upvote 0

parijs

Active Member
Licensed User
Longtime User
Hi Dallas,

Your first question was to copy Internal Storage to the External Storage.
But your code say External to External.
 
Upvote 0

Dallas Williams

Member
Licensed User
Longtime User
Hi Dallas,

Your first question was to copy Internal Storage to the External Storage.
But your code say External to External.

Thats correct. The file I want to copy lives in the internal storage however the call to the external storage actually picks up the file from the internal directory which is why I am so confused.

There is only one copy of the file on the device including storage. It has me somewhat confused. I originally put the file on the storage card and in the core directory, I only discovered later that it was using the internal file even though I was calling the external.

Maybe I haven't initialized my config properly somewhere?
 
Upvote 0

parijs

Active Member
Licensed User
Longtime User
Files what came from your install must be place in the filemap of your pc.
Your install place it in the File.DirAssets, if you are not root you cant find the file by filemanager.
If you copy the file it also stay in the File.DirAssets.

More about you can read here

I think you need something like this

B4X:
Dim TR As TextReader
Dim s As String
TR.Initialize(File.OpenInput(File.[location], fd.ChosenName))
   s = TR.ReadLine
   ...
TR.Close
 
Last edited:
Upvote 0

Dallas Williams

Member
Licensed User
Longtime User
Files what came from your install must be place in the filemap of your pc....

The file I wish to copy initially comes from a remote webserver and meant to be saved to the external storage:

B4X:
If HttpUtils.IsSuccess("http://192.168.1.12/results/RunOrder_Tablet.txt") Then
  therunorder = HttpUtils.GetInputStream("http://192.168.1.12/results/RunOrder_Tablet.txt")
  Dim out As OutputStream
  out = File.OpenOutput(File.DirDefaultExternal,"RunOrder_Tablet.txt",False)
  File.Copy2(therunorder , out)
  out.Close
End If

From here (because the file isn't written to the external storage) I was hoping to copy the file across to the external storage.

Maybe I am missing the point you are making but I'm ever so confused.
 
Upvote 0

Dallas Williams

Member
Licensed User
Longtime User
This saves the file to /Root/Android/data/net.dancescorelive.adj/files/RunOrder_Tablet.txt
B4X:
If*HttpUtils.IsSuccess("http://192.168.1.12/results/RunOrder_Tablet.txt")*Then
**therunorder*=*HttpUtils.GetInputStream("http://192.168.1.12/results/RunOrder_Tablet.txt")
**Dim*out*As*OutputStream
**out*=*File.OpenOutput(File.DirDefaultExternal,"RunOrder_Tablet.txt",False)
**File.Copy2(therunorder*,*out)
**out.Close
End*If

So I decided to see if I could actually read a file from the card.

I created a text file and copied it to the card called test.txt in the app files directory on the card.

File.Exists(File.DirRootExternal & "/extStorages/SdCard/Android/data/net.dancescorelive.adj", "test.txt")
Returns True

File.Exists(File.DirDefaultExternal, "test.txt")
Returns False

Log(File.DirDefaultExternal)
/mnt/sdcard/Android/data/net.dancescorelive.adj/files/

Log(File.DirRootExternal)
/mnt/sdcard/

Write External is also set in the manifest.
 
Upvote 0

Dallas Williams

Member
Licensed User
Longtime User
Well it looks like I've found my answer. Everywhere I look I'm now getting the same message.

3.2 Honeycomb does not support write access to an external storage card. It is read only, which is somewhat disappointing.
 
Upvote 0
Top