1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
public String readSettings(Context context, String pathFile){
FileInputStream fIn = null;
InputStreamReader isr = null;
char[] inputBuffer = new char[255];
String data = null;
try{
fIn = context.openFileInput(pathFile);
isr = new InputStreamReader(fIn);
isr.read(inputBuffer);
data = new String(inputBuffer);
//affiche le contenu de mon fichier dans un popup surgissant
Toast.makeText(context, " "+data,Toast.LENGTH_SHORT).show();
}
catch (Exception e) {
Toast.makeText(context, "Settings not read",Toast.LENGTH_SHORT).show();
Log.e("ReadSettings", e.getMessage());
Log.e("ReadSettings", e.toString());
}
finally {
try {
isr.close();
fIn.close();
} catch (IOException e) {
Log.e("ReadSettings", e.getMessage());
Log.e("ReadSettings", e.toString());
}
}
return data;
} |