Android Question create folder in android internal storage

Majed9621

Member
Licensed User
Hi to all
I am new here
Is it possible to create folder to internal storage and save files in it?
if yes please show me how
 

rraswisak

Active Member
Licensed User
yes, it is possible to create and copy file to internal storage

B4X:
'create NewFolder directory
File.MakeDir(File.DirInternal,"NewFolder")

'copy file to newly created folder
File.Copy(File.DirAssets,"a.txt",File.DirInternal & "/NewFolder", "a.txt")
or 
'make sure copy file finished before next code
Wait For (File.CopyAsync(File.DirAssets, "a.txt", File.DirInternal & "/NewFolder", "a.txt")) Complete (Success As Boolean)
 
Upvote 0

rraswisak

Active Member
Licensed User
You can find the file at app instalation directory, with file manager go to: Internal Storage/Android/Data/[your app package name]/files


Edited:
sorry i give you wrong information relate to app instalation folder. the correct was app instalation folder will remain invisible for other app to read (except you had root access) since it store in internal file system.

Folder Internal Storage/Android/Data/[your app package name] is locate in External file system which can be access by other app. to access this folder please see post #9
 
Last edited:
Upvote 0

Majed9621

Member
Licensed User
first: I can't find the folder in app package name
second: the app package name is different from the one I write it
it appears as Internal Storage/Android/Data/anywheresoftware.b4a.b4abridge/
how to change this (anywheresoftware.b4a.b4abridge) to the package name that I write
 
Upvote 0

Majed9621

Member
Licensed User
Yes I did that but I don't know why the package name is not changing
I use this as package name (com.mas.myapp.android) I don't know if this is valid for a package name
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

rraswisak

Active Member
Licensed User
Sorry for my previous code which does not work...

This code should works now:
B4X:
Dim rp As RuntimePermissions
rp.GetSafeDirDefaultExternal("")
File.MakeDir(File.DirDefaultExternal, "NewFolder")
File.Copy(File.DirAssets,"a.txt",File.DirDefaultExternal,"NewFolder/a.txt")

The full path would be in: Internal Storage/Android/data/[package name]/files/NewFolder/a.txt
 
Upvote 0
Top