不能(用perl-Android的APK)在Android上使用Perl脚本创建的文件 [英] Can't create file with Perl script on Android (using perl-android-apk)

查看:108
本文介绍了不能(用perl-Android的APK)在Android上使用Perl脚本创建的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要运行Android上的一个简单的Perl脚本。我使用的 Perl的Andr​​oid的APK 这使得它可能包括在一个APK Perl的跨preTER(基于 SL4A )。该项目配备了一个 hello.pl 脚本,它显示了一个敬酒。好吧,一切工作至今,所以我加了一些线文件创建 - 现在整个 hello.pl 脚本如下:

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

当我运行在Android上显示两个敬酒整个事情(你好..和再见。),但我无法找到文件 newtext.txt中的任何地方。我在做什么错了?

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?

推荐答案

请问您的Andr​​oid清单有这个?

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();

也许你可以调用Java和它传递给你的Perl脚本作为参数?

Maybe you could call that in Java and pass it to your perl script as an argument?

这篇关于不能(用perl-Android的APK)在Android上使用Perl脚本创建的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆