Android FileOutStream: can not find my saved txt file - Android Q&A, Help & Troubleshooting

hello, everyone,
I'm an newbie developer for android device.
Recently I want to save my data into an txt file using FileOutputStream.
Here is my code:
Code:
FileOutputStream outStream=this.openFileOutput("2222.txt",Context.MODE_APPEND + Context.MODE_WORLD_READABLE);
String data1 = Float.toString(cpuUsage);
Log.i("savedata",data1);
outStream.write(data1.getBytes());
outStream.close();
The code worked perfectly.
But the problem is I can not find where to see this file on my computer.
I was told that the fileoutstream will ususally save file in data/(packages name)/files.
But data directory is empty in file explorer on Eclipse.
Anybody please help..
Best

Related

[Q] Copy file from sdcard to Samba network directory

Hi, We have installed ES File Explorer on our Android tablet and we have cataloged a remote server (10.10.19.45). I am able to see the files on this server from the tablet.
On a different desktop project, I have used a java.nio class file to copy files from a local folder on the desktop to the same remote server and it has been working fine. I tried to use the same java class to copy a file from the Android /sdcard/Download directory to the remote server and it will not create the file on the remote server. I tried specifying
File DestinationFile = new File("//10.10.19.45/sandbox/result.txt"); AND
File DestinationFile = new File("smb://10.10.19.45/sandbox/result.txt");
but neither one works. I keep getting the error "IOException: No such File or Directory". The first option worked for my regular desktop Java application. Is there anyway I can copy files from my sdcard/download directory to the samba directory I have catalogued on my Android? Thanks.

[Q] ApplyRecovery.bat

this is gonna sounds stupid but i followed every step but i cant seem to get the file to be only ApplyRecovery.bat, thats how i named the files but it does only open notepad....like if it was reading ApplyRecovery.bat.txt
Step 5: create a text file using notepad, called ApplyRecovery.bat. Make sure it is not named "ApplyRecovery.bat.txt" . It will contain the following lines (copy/paste is fine)
i did it finally
For future reference, it might help others if you explained how you solved your problem. For example, given this issue where the file is opening in notepad, one of the following possibilities is apparent:
1. When saving the file, you did not enclose the file name in quotes, e.g. "ApplyRecovery.bat". Enclosing the file name in quotes overrides the automatic generation of extensions and saves the file exactly as you wish.
2. Batch files, files ending in .bat, were set to open in notepad instead of being ran when double-clicked. This would by necessity require you to delete the file association before the batch file would work.

Android File object mkdirs with accents

Hi,
I'm using the Java File object to create diretories, however a folder containing an accent won't be created, for example
File f = new File ("/sdcard/sécurité/");
f.mkdirs();
the folder sécurité won't be created and no error will be raisen
however
File f = new File ("/sdcard/securite/");
f.mkdirs();
does work
Any idea ?
Thank you !

[Q] how to make writable external sd on kitkat? (yes again)

hi Everyone,
I'm sticked with the common issue of how to make writable the external SD.
I've read topics on the forum:
http://forum.xda-developers.com/desire-601/help/how-to-writable-external-sd-kitkat-t2877686
http://forum.xda-developers.com/desire-601/help/sd-card-permissions-off-t2833195
http://forum.xda-developers.com/showthread.php?t=2687734
Well ok, but I'm a noob so sometimes it's not clear, sometimes it's not working for me.
So let's explain:
- My device is rooted (it was made by a tech using TWRP if I'm right)
- SuperSU is installed
1/ I tried some apps like SDfix and Int-SDCard Write fix
> Result = KO
2/ I tried to manually modify the platform.xml file > sometimes the editor does not want to save the modification, sometimes it says OK but the file don't seem to be modified (the last modification date is still 2014). Permissions are: rw-r--r--
a. Using Rom Toolbox, I go the file and edit it with:
-FX TextEdit > Get a Warning = "This file is on read-only filesystem. You will not be able to save any changes unless you first remount it as read/write'
> Result = KO
- RB Text Editor: it seems i can edit it. Save the file without warning message 'Saved'. But once back on the /system/etc/permissions folder, nothing looks modified (not today's date). I can reopen the file and see the modification by the way. But once I reboot, I go back the my original issue.
> Result = KO
- ES Text editor: can't even save the file
> Result = KO
So what ?
I've seen this message coming along:
"if you are rooted then you doing something wrong (did you maybe forgot to mount system as R/W ?).
If you are unable to do modify platform.xml then you doing something wrong or yours device isnt rooted."
> At what moment is it possible to mount the system with R/W grants ?
I'm fed up with not being able to write on SD card....................
Thx in advance !!!!!
Opening a terminal on my phone:
- i can't 'cp file1.xml file2.xml' in /system/etc/permissions
- i can't 'chmod 644 file1.xml'
Each I get "Read-only file system"
Flash your stock kernel with insertcoin or kofilakernel

Sharing text file programatically

Hi, I am quite new to Android development. I need to share a text file from my Android app via WhatsApp, mail etc. I am using the below code:
File file = new File(stringFile);
Intent intentShare = new Intent(Intent.ACTION_SEND);
intentShare.setType("text/*");
intentShare.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+file));
startActivity(Intent.createChooser(intentShare, "Share the file ..."));
stringFile contains the full path of my file. The file is in internal storage. When I run the above code. I am getting the share apps like WhatsApp. gmail etc.
i am also able to select the requited app( say gmail) and proceed. But the thing is the file is not sent at all.
Is there anything I need to do in special? The file is created in internal storage. The path is /data/user/0/com.example.myappname/files/myfile.txt
Kindly help.Thanks
The receiving app has no permission to access the data your file://Uri points to.
I think you should store the data in your own ContentProvider or system MediaStore in order for the receiving app to have access to the text file.
If you will store the file in your own ContentProvider, you should pass the Content Uri into the function call intentShare.putExtra() then.

Categories

Resources