问题
I want to run a simple Perl script on Android. I am using perl-android-apk which makes it possible to include the Perl interpreter in one APK (based on SL4A). The project comes with a hello.pl
script, which shows a toast. Alright, everything working so far, so I added some lines for file creation - now whole hello.pl
script looks like:
use Android;
my $a = Android->new();
$a->makeToast("Hello, Android!");
open(TEXT,">newtext.txt") || $a->makeToast("I died.");
print TEXT "Check out our text file!";
close(TEXT);
$a->makeToast("Bye, Android!");
When I run the whole thing on Android both toasts are shown ("Hello.." and "Bye..") but I can't find the file newtext.txt
anywhere. What am I doing wrong?
回答1:
Does your Android manifest have this?
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Also, you might not be able to write to that location. Other answers here indicate that you need to get the external storage directory:
Environment.getExternalStorageDirectory();
Maybe you could call that in Java and pass it to your perl script as an argument?
来源:https://stackoverflow.com/questions/19291600/cant-create-file-with-perl-script-on-android-using-perl-android-apk