0

To read the data from the attached file I use:

Uri dataUri = getIntent().getData();
ContentResolver cr = getContentResolver();
String readXmlString = "";
try {
    InputStream inputStream = cr.openInputStream(dataUri);
    readXmlString = FileUtils.readFromInputStream(inputStream);
} catch (FileNotFoundException e) {
    e.printStackTrace();
}

On most devices this code works fine, but on Kindle Fire I have a problem. I have debugged it. The problem occurs when content resolver tries to open input stream. So, I have something like this in readXmlString: �۝�+v�(�קi�^����%z��ܩz��ʗ����

The code of my readFromInputStream:

public static String readFromInputStream(InputStream inputStream){
    StringBuilder total = new StringBuilder();
    try {
        BufferedReader r = new BufferedReader(
                new InputStreamReader(inputStream)); //also tried: new InputStreamReader(inputStream, "UTF-8")
        String line;
        while ((line = r.readLine()) != null) {
            total.append(line);
        }
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return total.toString();
}
Alex Kucherenko
  • 20,168
  • 2
  • 26
  • 33
  • It looks like the email app is providing binary only. Which docs are you using to try to read as XML? I'd be very surprised if the email app uses any xml under the covers. –  Mar 15 '12 at 09:18
  • It's very strange, but now this problem isn't observing. – Alex Kucherenko Mar 21 '12 at 08:33

0 Answers0