I am building an application in which I want to send bytearray from one activity to another. In order to do so I have saved the data in the file in byte form 'data1.txt'. At the time of retrieval the app slows down and stops working. This is the code
public void read(String file) {
String ret = "";
try {
InputStream inputStream = openFileInput(file);
if ( inputStream != null ) {
InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
String receiveString = "";
while ( (receiveString = bufferedReader.readLine()) != null ) {
ret=ret.concat(receiveString);
}
theByteArray = ret.getBytes();
inputStream.close();
}
} catch (FileNotFoundException e) {
Toast.makeText(getBaseContext(), "File not found: " + e.toString(), Toast.LENGTH_LONG).show();
} catch (IOException e) {
Toast.makeText(getBaseContext(), "Can not read file: " + e.toString(), Toast.LENGTH_LONG).show();
}
}