Go for a walk for an hour and try to think about something else. Then
when you get back start again from first principles.
On 10/24/2011 7:08 AM, melis wrote:
Hi all,
i really tried hard but couldn't achieve to create or any other file
operations in Android. First thing i did was tp check the availabilty
of the SD card media, with the sample code here:
http://developer.android.com/guide/topics/data/data-storage.html#filesExternal.
I have the media and works properly.
Then i tried to create a .txt file with this code snippet:
File myFile = new File("/sdcard/mysdfile.txt");
myFile.createNewFile();
FileOutputStream fOut = new FileOutputStream(myFile);
OutputStreamWriter myOutWriter = new
OutputStreamWriter(fOut);
myOutWriter.append(txtData.getText());
myOutWriter.close();
fOut.close();
also tried this one, which works in the Java project but not in
android:
String path = "/sdcard/data.txt";
File dosya = new File(path);
dosya.createNewFile();
last thing i tried is another sample code from android developers;
private void createExternalStoragePrivateFile() {
// TODO Auto-generated method stub
File file = new File(getExternalFilesDir(null),"DemoFile.jpg");
InputStream is =
getResources().openRawResource(R.drawable.icon);
try {
OutputStream os = new FileOutputStream(file);
byte[] data = new byte [is.available()];
is.read(data);
os.write(data);
os.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.w(" External Storage ", " Error writing " + file,
e);
}
}
I'm getting no errors but also no files in the sd card. And i don't
forget to add<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> permission
line into the manifest.
I'm checking the F driver after executing the program to see if any
txt file created, but nothing happened so far. I read SD card is not
available when the android device is hooked up to the computer via USB
in somewhere. To check this possibility, i also looked at the sd
card's context with an laptop sd card adapter but again, i have
nothing.
Please someone help me. I'm out of ideas.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en