android - How do I use the value of a variable AS a variable -
haven't come across in coding android yet. how utilize value of 1 variable new variable.
i want take value of variable "file1.mp3" strip off extension , append text variable , utilize variable name file1_title.txt , file1_desc.txt.
so fname[1] might equal file1.mp3
and want create new variable
file1_title.txt equals "song title one"
file1_desc.txt equals "description of file one"
both based on value of fname[1]
fname[2] equals file2.mp3
file2_title.txt equals "song title two"
file2_desc.txt equals "description of file two"
both based on of value fname[2]
etc...
how done android
not sure if you're looking for. basic java string formating.
string attr1 = "song.mp3"; string attr2 = attr1.split(".")[0] + ".txt";
naturally add together necessary null checks.
==update==
so if understand correctly, file name ("asd.mp3") , need song title , description.
string attr1 = "song.mp3"; string songname = ""; string songdesc = ""; string[] splitarray = attr1.split("."); if(splitarray[0] != null){ string songname = attr1.split(".")[0]; file f = new file(path + songname +".txt"); //i didn't quite understand in format data, //especially description. however, in map //where songname key, suggested above, , here write description file(f)
}
android variables
No comments:
Post a Comment