Example #1
0
 public static void readModelfromFile(MainActivity obj) {
   File sdcard = obj.getExternalFilesDir(null);
   File ModelFile = new File(sdcard, Globals.MODEL_FILE_NAME);
   try {
     FileInputStream fin = new FileInputStream(ModelFile);
     ObjectInputStream ois = new ObjectInputStream(fin);
     _model = (svm_model) ois.readObject();
     ois.close();
   } catch (Exception ex) {
     ex.printStackTrace();
   }
 }
Example #2
0
  public static void writeModeltoFile(ActionBarActivity obj) {
    // Write SVM Model

    File sdcard = obj.getExternalFilesDir(null);
    File ModelFile = new File(sdcard, Globals.MODEL_FILE_NAME);
    try {
      FileOutputStream fout = new FileOutputStream(ModelFile);
      ObjectOutputStream oos = new ObjectOutputStream(fout);
      oos.writeObject(_model);
      oos.close();
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }