16 Android 文件存储

OnClickListener listern3 = new OnClickListener() {

		public void onClick(View v) {
			// TODO Auto-generated method stub

			String str = "flie2";
			try {
				FileOutputStream fos = openFileOutput(FILE2,
						Context.MODE_PRIVATE);
				fos.write(str.getBytes());
				fos.close();
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

		}
	};

	OnClickListener listern4 = new OnClickListener() {

		public void onClick(View v) {
			// TODO Auto-generated method stub
			try {
				FileInputStream fis = openFileInput(FILE2);
				String str = "";
				int length = fis.available();
				byte[] buffer = new byte[length];
				fis.read(buffer);
				str = buffer.toString();
			
				Toast.makeText(StroeDataActivity.this, str + "是",
						Toast.LENGTH_LONG).show();
				fis.close();
			} catch (Exception e) {
				e.printStackTrace();
			}

		}
	};

你可能感兴趣的:(16 Android 文件存储)