Dim Success as boolean
Success=RenameFile(File.DirRootExternal & "/path/oldfilename.txt", File.DirRootExternal & "/path/newfilename.txt")
Sub RenameFile(OriginalFileName As String, NewFileName As String) As Boolean
Dim Result As Int
Dim StdOut, StdErr As StringBuilder
StdOut.Initialize
StdErr.Initialize
Dim Ph As Phone
Result = Ph.Shell("mv " & OriginalFileName & " " & NewFileName, Null, StdOut, StdErr)
If Result = 0 Then
Return True
Else
Return False
End If
End Sub
Thanks so much mangojack and marcick for the code example.. I will run and test them.
DonManfred,
Thanks for the time you are taking to interact in this thread.
You said, what it means, that I used b4a for two years and therefore I don't deserve the kind of detailed help I need.
1- yes I own the license for about 2 years, but it is not true that I used or had the time to study b4a for 2 years.
2- At the time you hit the send key, then the question does not belong to you only.. so many new comers will be interested in the answer. In this way, the whole forum should be considered as FAQs. that every visitor, be it a member or not can benefit from it.
3- Since you first advised me, now I also have the right to advice you that there is only one alpha in this forum, and we should refrain from telling people. I am a member and only have the right to answer a posted question if I have an answer, or read other people's answers so I can learn a new thing.
Finally, and don't take me wrong, everything I have said is without prejudice to your right to freedom of speech.
1) I did not say you have studied B4A for 2 years. I just mention that you ARE using B4A. 727 posts from you in this forum speaks his own language... You cannot be a newbie i suppose
Everything i said was that you SHOULD be ABLE (with 727 posts here) to find the code for Copying and Deleting a file here in forum or in the documentation. This commands are part of the core-lib which is marked on every new Project you create.
In fact you got the solution to your issue with the first answer you got
2) I fully agree
3) i agree to this too.
Finally, and don't take me wrong, everything I have said is without prejudice to your right to freedom of speech. ;-)
Klaus,
danke.. It's very important to know that any data on the assets directory is read-only and can not be edited by app users, this
means that if one wants a text file to be edited and saved at runtime, then they should save it in the external SD card.
This is the point. DirInternal is internal, read-write space, for the App not necessarily internal memory or external memory (as some devices don't have external memory capabilities).
It really depends, as klaus mentioned, what you are trying to achieve here. Are you saving a file that is for use by the App only or for sharing with other Apps or available outside of the App.
If the file is only used by your application use DirInternal.
If the file must be accessible from another application use DirRootExternal or DirDefaultExternal. You need to check if external storage is avalable.
If you have a file in DirAssets and want to write to it you must copy it somewhere else.
Thanks guys, I think I am getting it now..
I have a table of contacts, (not the phone contacts).. and I want to open and add, edit and delete entries..., so from what you said here, the right place is the external SD card. (not DirAssets, not DirInternal)