2

我想在 Android 上运行一个简单的 Perl 脚本。我正在使用perl-android-apk,它可以将 Perl 解释器包含在一个 APK 中(基于SL4A)。该项目附带一个hello.pl脚本,其中显示了祝酒词。好的,到目前为止一切正常,所以我添加了一些文件创建行 - 现在整个hello.pl脚本看起来像:

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!");

当我在 Android 上运行整个过程时,都会显示两个 toast(“Hello..”和“Bye..”),但我在任何地方都找不到该文件newtext.txt。我究竟做错了什么?

4

1 回答 1

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?

于 2013-10-15T16:13:53.570 回答