@Override protected void onPostExecute(File result) { super.onPostExecute(result); SharedPreferences sharePref = mContext.getSharedPreferences(Constant.PREFERENCE_FILE_NAME, Context.MODE_PRIVATE); Editor edit = sharePref.edit(); edit.putBoolean(Constant.KEY_IS_DATA_COPIED, true); edit.putString(Constant.KEY_PATH_TESS_DATA, result.getParent()); edit.putString(Constant.KEY_LANG_TESS, "vie"); edit.commit(); }
public static void createTessDataNotAsync() { InputStream in = mContext.getResources().openRawResource(R.raw.vie); OutputStream out = null; File folder = null; folder = createTessDataFolder(); if (folder == null) { throw new NullPointerException("Not able to create tessData"); } File fileCP = new File(folder, "/vie.traineddata"); try { out = new FileOutputStream(fileCP); byte[] buffer = new byte[1024]; int countRead = 0; while ((countRead = in.read(buffer)) != -1) { out.write(buffer, 0, countRead); } } catch (FileNotFoundException fnfE) { fnfE.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { in.close(); out.close(); } catch (IOException e) { e.printStackTrace(); } } File tessdataFolder = fileCP.getParentFile(); SharedPreferences sharePref = mContext.getSharedPreferences(Constant.PREFERENCE_FILE_NAME, Context.MODE_PRIVATE); Editor edit = sharePref.edit(); edit.putBoolean(Constant.KEY_IS_DATA_COPIED, true); edit.putString(Constant.KEY_PATH_TESS_DATA, tessdataFolder.getParent()); edit.putString(Constant.KEY_LANG_TESS, "vie"); edit.commit(); }