Solved

Save Filed

Posted on 2012-03-27
1
332 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Callkit and Android comparison 4 43
Android releases 7 46
How do I return the Android Studio to its default project window settings? 6 69
spam sms 9 35
I tend toward trying the newest hardware and software.  Thiss sometimes works out to my benefit, and sometimes not.  Because I downloaded and installed Android 5.x (http://www.experts-exchange.com/articles/18084/Upgrading-to-Android-5-0-Lollipop.htm…
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.
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…

785 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