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
Solved

Save Filed

Posted on 2012-03-27
1
333 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:
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

This is an explanation of a simple data model to help parse a JSON feed
A short article about problems I had with the new location API and permissions in Marshmallow
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…

766 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