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();
}