Android Question ExternalStorage - Rename a folder.

agraham

Expert
Licensed User
Longtime User
No guarantees but try this, where AnExternalFile is an ExternalFile returned by FindFile. Result is True if it succeeds
B4X:
Dim NewName as String = "NewName"
Dim result as Boolean
Result = AnExternalFile.Native.RunMethod("renameTo", Array(NewName))
 
Upvote 2

agraham

Expert
Licensed User
Longtime User
Comments for renameTo from the Android API reference for DocumentFile which is what the Native member of ExternalFile is
Renames this file to displayName.

Note that this method does not throw IOException on failure. Callers must check the return value.

Some providers may need to create a new document to reflect the rename, potentially with a different MIME type, so getUri and getType may change to reflect the rename.

When renaming a directory, children previously enumerated through listFiles may no longer be valid.
 
Upvote 0
No guarantees but try this, where AnExternalFile is an ExternalFile returned by FindFile. Result is True if it succeeds
B4X:
Dim NewName as String = "NewName"
Dim result as Boolean
Result = AnExternalFile.Native.RunMethod("renameTo", Array(NewName))
Thank you very much, I will try to do it.
 
Upvote 0
No guarantees but try this, where AnExternalFile is an ExternalFile returned by FindFile. Result is True if it succeeds
B4X:
Dim NewName as String = "NewName"
Dim result as Boolean
Result = AnExternalFile.Native.RunMethod("renameTo", Array(NewName))
Works great!
Thanks for the help, it was very important for my Project.
 
Upvote 0
Top