Android Question Create a folder under the root of SD card (B4A)

AndyChang

Member
Licensed User
Hi

It will be very helpful if I can create a folder under the root of SD card. I search around the forum, It seems that until now, it still cannot create a folder under the root of SD card. Am I right?

Andy
 

AndyChang

Member
Licensed User
If I want to create a new folder named NailFans, how do I code the new_folder.

Dim Sqlname3 As String="Mydesign.sqlite3"
Dim new_folder As String="root\NailFans" ' <------ I don't know how to define new_folder
OpenSQLitefile(Sqlname3)
File.MakeDir(File.DirRootExternal,"new_folder") ' <----- the statement is put here?
SQL3.Initialize(File.DirRootExternal, Sqlname3, True)

Andy
 
Upvote 0

AndyChang

Member
Licensed User
Sorry, I have to explain again.
I define fileDir = "D:\test"
B4X:
Sub OpenSQLitefile(SN As String)
    File.MakeDir(File.DirRootExternal, fileDir)                                        'To define a External root Dir here is very important
    If File.Exists(File.DirRootExternal, SN) = False Then
        File.Copy(File.DirAssets, SN, File.DirRootExternal, SN)
    End If
End Sub
[\code]
No data file being put into D:\test
All files are in the root
Andy
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
oh you use filedir there...

then this should work I guess

B4X:
File.Copy(File.DirAssets, SN, File.DirRootExternal & "\" & fileDir, SN)
 
Upvote 0

AndyChang

Member
Licensed User
B4X:
Sub OpenSQLitefile(SN As String)
    File.MakeDir(File.DirRootExternal, "\NailFans")                                        'To define a External root Dir here is very important
    If File.Exists(File.DirRootExternal, SN) = False Then
        File.Copy(File.DirAssets, SN, File.DirRootExternal&"\NailFans", SN)
    End If
End Sub
[code\]

An folder has been created successfully. But there is no file inside the folder. The file still located in root.
Andy
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
your check is wrong so it probably sees the document in the root and skips the right copy method

B4X:
If File.Exists(File.DirRootExternal & "\NailFans", SN) = False Then
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Your code should be this:
B4X:
Sub OpenSQLitefile(SN As String)
    File.MakeDir(File.DirRootExternal, "\NailFans")                                        'To define a External root Dir here is very important
    If File.Exists(File.DirRootExternal & "/\NailFans", SN) = False Then
        File.Copy(File.DirAssets, SN, File.DirRootExternal & "/\NailFans", SN)
    End If
End Sub
 
Upvote 0

AndyChang

Member
Licensed User
Dear Mahares,
I works. I feel so happy for I can have this very important function.
Thank you so much. And Thanks a lot to sorex and Manfred for your enthusiastic and prompt answers.
Andy
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…