Solved

Save Filed

Posted on 2012-03-27
1
335 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 8

Accepted Solution

by:
Santhana earned 500 total points
ID: 37774960
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You should read OS supplied guidelines before developing. I can't stress that enough. The guidelines will help you understand the reasons mobile app developers do what they do.  Apple is very particular when they review appstore submissions.
These days software publishers make it possible to move all the possible applications on smartphones, tablets, smartwatches, and more. Although behind every logic and decision is a gross doubt: how do they make it possible? In this blog post, we sha…
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.
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

691 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