[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Save Filed

Posted on 2012-03-27
1
Medium Priority
?
339 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 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This is an explanation of a simple data model to help parse a JSON feed
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
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…

649 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