Running prolog in Android

烈酒焚心 提交于 2019-12-08 08:02:30

I've done it before and have posted the (very, very beta proof of concept only) source code for interrogation, pls see below.

To download the Eclipse (Helios) project Source Code, goto: versaggi.biz, Downloads Adrea, TuProlog Dev Project, Eclipse (Helios) Java Source Project, and finally to TuProlog Android Eclipse Porject Source. That should get you started. Please keep in mind that this is proof of concept code ONLY and is will be completely rewritten before the final version is released. Given that, it does work well enough for you to get some insights into how I did what I did. If you want any assistance at all just contact me directly and I'll be glad to help you along. :-)

Joonas Pulakka

I get FileNotFoundException even though my file data.pl is copied in root of project

But look at the error:

java.io.FileNotFoundException: /data.pl (No such file or directory)

It's trying to read data.pl from root of the file system!

You could try using FileInputStream(File) constructor for more control over the path. Have a look at for example this question on how to get application's directory.

Savio
  1. In eclipse, create a folder "plFiles" in the res folder of your project
  2. Move your pl files to this folder (eg: res/plFiles/data.pl)
  3. Use the activity to access this file using (a is the current activity)

    InputStream in = a.getResources().openRawResource(R.plFiles.data);
    
  4. The above line returns an InputStream. You may now use Scanner or BufferedReader or any reader class of your liking to continue parsing or reading the file.

Another way to access files is mentioned here ... Access resource files in Android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!