Solved

Save Filed

Posted on 2012-03-27
1
330 Views
Last Modified: 2012-04-02
I've attached the code. I'm having 2 problems with it.

The code shows the onClick method. Every time I click on th save button, I want a new file to be created and saved on the SD card, and then in the txtInput to display all the files on the SD card.

1st problem. Every time I click the save button, it seems to overwrite the existing file because it only shows one file in the txtInput as a result.

2nd problem. It shows the wrong file name in the txtInput results. If the 1st sentence I typed was "This is a test", then the filename was suppose to be This_0.wav, which is what the text box shows for the results. The next time I type a different sentence. "Type text here". The filename is suppose to be Type_0.wav, but it's not. It's still showing This_0.wav.
main.java
0
Comment
Question by:InfoTechEE
1 Comment
 
LVL 8

Accepted Solution

by:
santhanasamy earned 500 total points
Comment Utility
Hi InfoTechEE,

1st problem. Every time I click the save button, it seems to overwrite the existing file because it only shows one file in the txtInput as a result.
In this for loop every time you are setting
for(int j=0;j<mfile.listFiles().length;j++){
      txtInput.setText(list[j].getAbsolutePath() + " " + saveText.substring(0, spacePosotion));
}
Here every time you are setting a new text. So it will display only one file name that is the last file in the array  list.

If you want to see all the files in the /sdcard use following code. It will display each file in single line.

StringBuilder lBuilder = new StringBuilder();
for(int j=0;i<mfile.listFiles().length;j++){
  lBuilder.add(list[j].getAbsolutePath() + " " + saveText.substring(0, spacePosotion) +"\n");
}
txtInput.setText(lBuilder.toString());


2)nd problem. It shows the wrong file name in the txtInput results.

Here also same problem....It will always display the last file name,,,,
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

I recently asked a question (http://www.experts-exchange.com/Programming/Smartphones/Android/Q_28684946.html) about Computer Inventory applications for Mobile Devices.  I was specifically interested in an app I could use on my android phone.  The be…
The case of the missing phone talks about the way a small electronic gadget (the mobile phone) has penetrated into our lives and has made us addicted to it.
This video is in connection to the article "The case of a missing mobile phone (https://www.experts-exchange.com/articles/28474/The-Case-of-a-Missing-Mobile-Phone.html)". It will help one to understand clearly the steps to track a lost android phone.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now