Code for reading and writing local files under Android system

From , 5 Years ago, written in Java, viewed 76 times.
URL https://pastebin.vip/view/77143919
  1. public String ReadSettings(Context context){
  2.       FileInputStream fIn = null;
  3.       InputStreamReader isr = null;
  4.      
  5.       char[] inputBuffer = new char[255];
  6.       String data = null;
  7.      
  8.       try{
  9.        fIn = openFileInput("settings.dat");      
  10.           isr = new InputStreamReader(fIn);
  11.           isr.read(inputBuffer);
  12.           data = new String(inputBuffer);
  13.           Toast.makeText(context, "Settings read",Toast.LENGTH_SHORT).show();
  14.           }
  15.           catch (Exception e) {      
  16.           e.printStackTrace();
  17.           Toast.makeText(context, "Settings not read",Toast.LENGTH_SHORT).show();
  18.           }
  19.           finally {
  20.              try {
  21.                     isr.close();
  22.                     fIn.close();
  23.                     } catch (IOException e) {
  24.                     e.printStackTrace();
  25.                     }
  26.           }
  27.           return data;
  28.      }
  29.  
  30.  
  31. //java/6366

Reply to "Code for reading and writing local files under Android system"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website