List of usage examples for android.app Application openFileInput
@Override public FileInputStream openFileInput(String name) throws FileNotFoundException
From source file:com.ichi2.anki.Feedback.java
private static List<NameValuePair> extractPairsFromError(String type, String errorFile, String groupId, int index, Application app) { List<NameValuePair> pairs = new ArrayList<NameValuePair>(); pairs.add(new BasicNameValuePair("type", "crash-stacktrace")); pairs.add(new BasicNameValuePair("groupid", groupId)); pairs.add(new BasicNameValuePair("index", String.valueOf(index))); addTimestamp(pairs);/*from w ww. j a v a2 s .c o m*/ String singleLine = null; try { BufferedReader br = new BufferedReader(new InputStreamReader(app.openFileInput(errorFile))); while ((singleLine = br.readLine()) != null) { int indexOfEquals = singleLine.indexOf('='); if (indexOfEquals == -1) { continue; } String key = singleLine.substring(0, indexOfEquals).toLowerCase(Locale.US); String value = singleLine.substring(indexOfEquals + 1, singleLine.length()); if (key.equals("stacktrace")) { StringBuilder sb = new StringBuilder(value); while ((singleLine = br.readLine()) != null) { sb.append(singleLine); sb.append("\n"); } value = sb.toString(); } pairs.add(new BasicNameValuePair(key, value)); } br.close(); } catch (FileNotFoundException e) { Log.w(AnkiDroidApp.TAG, "Couldn't open crash report " + errorFile); return null; } catch (IOException e) { Log.w(AnkiDroidApp.TAG, "Couldn't read crash report " + errorFile); return null; } return pairs; }
From source file:com.hichinaschool.flashcards.anki.Feedback.java
private static List<NameValuePair> extractPairsFromError(String type, String errorFile, String groupId, int index, Application app) { List<NameValuePair> pairs = new ArrayList<NameValuePair>(); pairs.add(new BasicNameValuePair("type", "crash-stacktrace")); pairs.add(new BasicNameValuePair("groupid", groupId)); pairs.add(new BasicNameValuePair("index", String.valueOf(index))); addTimestamp(pairs);//from ww w . ja v a 2 s. c o m String singleLine = null; try { BufferedReader br = new BufferedReader(new InputStreamReader(app.openFileInput(errorFile))); while ((singleLine = br.readLine()) != null) { int indexOfEquals = singleLine.indexOf('='); if (indexOfEquals == -1) continue; String key = singleLine.substring(0, indexOfEquals).toLowerCase(); String value = singleLine.substring(indexOfEquals + 1, singleLine.length()); if (key.equals("stacktrace")) { StringBuilder sb = new StringBuilder(value); while ((singleLine = br.readLine()) != null) { sb.append(singleLine); sb.append("\n"); } value = sb.toString(); } pairs.add(new BasicNameValuePair(key, value)); } br.close(); } catch (FileNotFoundException e) { Log.w(AnkiDroidApp.TAG, "Couldn't open crash report " + errorFile); return null; } catch (IOException e) { Log.w(AnkiDroidApp.TAG, "Couldn't read crash report " + errorFile); return null; } return pairs; }