How to write an external text file in Android?

I want to write a string string in a text file in an android project (using Eclipse). This is the code I'm trying but not working ...

    String s="hello azeem\n";
    try{
    FileOutputStream fos = openFileOutput("C:\\eventslog.txt", Context.MODE_PRIVATE);
    fos.write(s.getBytes());
    fos.close();
    }
    catch (Exception e){

    }

Any ideas?

0
source share
3 answers

There are two ways to understand your question:

+4

Android SD- . Android Bridge (adb.exe, sdk\platform-tools), txt ... - Windows.

( foo.txt android)

bar.bat:

adb pull /sdcard/Android/data/com.example.yourapp/files/foo.txt C:\foo.txt

bar.bat. . foo.txt sdcard C:\foo.txt

, . Windows.

+1

You may not have added his permission ...

here:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
-1
source

All Articles