Click here to Skip to main content
15,889,542 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to save string from textview to a file.
in different location with the help of radio button,

i am using radio button and save button.

now i can save the file. in different folder selecting folder will be by
radio button.

can u help please

What I have tried:

btnSave.setOnClickListener(new View.OnClickListener()
{
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date now = new Date();
            String fileName = "TFR_"+formatter.format(now) + ".txt";//like 2016_01_12.txt

            @Override
            public void onClick(View v)
            {
                try
                {
                    File root = new File(Environment.getExternalStorageDirectory()+ "Dhananjay", "A1");
                    
                    if (!root.exists())
                    {
                        root.mkdirs();
                        root.createNewFile();
                    }
                    File gpxfile = new File(root, fileName);
                    FileWriter writer = new FileWriter(gpxfile,true);
                    writer.write(tvTerminal.getText()+"\n\n");
                    writer.flush();
                    writer.close();
                    clear.setVisibility(View.VISIBLE);
                }
                catch(IOException e)
                {
                    e.printStackTrace();
                }
            }
        });
Posted
Updated 7-Jun-18 19:29pm
v2
Comments
Mohibur Rashid 8-Jun-18 0:17am    
Dose this mean, you will put the location name in radio button, on user selection you will save the data in selected path. If so, your problem is you can't identify which radio button is selected. Or what?
Member 13307200 8-Jun-18 6:46am    
Dose this mean, you will put the location name in radio button, on user selection you will save the data in selected path.
yes sir i want save with radio button selected path.
i tried with if checked
switch case i am unable to save.
with different folder each time check radio button and save button
David Crow 8-Jun-18 10:17am    
"i tried with if checked
switch case i am unable to save.
with different folder each time check radio button and save button"

I realize English may not be your first, or second, language, but I am completely unable to understand what you are asking here.

The code you've shown executes when the Save button is clicked. I see nothing that checks the status of any radio button.
Dave Kreskowiak 8-Jun-18 0:43am    
So, what's the problem?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900