Skip to content

Instantly share code, notes, and snippets.

@tuttelikz
Created February 9, 2018 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuttelikz/d3de39f8fa14fb0d5aba6aa29ffabdc1 to your computer and use it in GitHub Desktop.
Save tuttelikz/d3de39f8fa14fb0d5aba6aa29ffabdc1 to your computer and use it in GitHub Desktop.
This is a function to load text from storage
public void load(View view) {
try {
FileInputStream fileInputStream = openFileInput("vivz.txt");
int read = -1;
StringBuffer buffer = new StringBuffer();
while((read=fileInputStream.read())!=-1) {
buffer.append((char) read);
}
Log.d("VIVZ",buffer.toString());
String text1 = buffer.substring(0,buffer.indexOf(" "));
String text2 = buffer.substring(buffer.indexOf(" "+1));
username.setText(text1);
password.setText(text2);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Toast.makeText(this,"Load successful",Toast.LENGTH_SHORT).show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment