0

i'm writing an android application that uses fuzzy inference for showing final result on one of my activities. I use jFuzzyLogic library for this purpose , and first of all i want to only run famous tipper fuzzy problem in my app ,
but when i write below code in my onCreate method , and run the app , app closes and stops running!

i guess it can't load FIS file "tipper.fcl" can anybody help please

thanks

here is my onCreate method :

 protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    //context = MainActivity.this;

    double out=0;
    String error = "can't load fis" ;

    my_textview = (TextView) findViewById(R.id.output_tv);

    String fileName = "tipper.fcl";
    FIS fis = FIS.load(fileName, true); // Load from 'FCL' file
    if (fis == null) {
        my_textview.setText(error);

    }

    fis.setVariable("service", 3);
    fis.setVariable("food", 7);
    fis.evaluate();
    out = fis.getVariable("tip").getValue();
    my_textview.setText(String.valueOf(out));

}
rjzii
  • 14,236
  • 12
  • 79
  • 119
Eldar
  • 1
  • 1

1 Answers1

1

1.Create Assets Folder And Inside it put tipper.fcl file.
2.Take InputStream and pass asset Folder Path
3.Like this
InputStream is =getApplicationContext().getAssets().open("tipper.fcl");
4.finally pass InputStream object in FIS.load method like this
FIS fis = FIS.load(is, true);

ApRaJrUtNh
  • 11
  • 1