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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
| EditText verifi;
Button verification2;
public String ReadSettings(Context context){
FileInputStream fIn = null;
InputStreamReader isr = null;
char[] inputBuffer = new char[255];
String data = null;
try{
fIn = context.openFileInput("fichier.txt");
isr = new InputStreamReader(fIn);
isr.read(inputBuffer);
data = new String(inputBuffer);
Toast.makeText(context, " "+data,Toast.LENGTH_SHORT).show();
}
catch (Exception e) {
Toast.makeText(context, "Settings not read",Toast.LENGTH_SHORT).show();
}
finally {
try {
isr.close();
fIn.close();
} catch (IOException e) {
Toast.makeText(context, "Settings not read",Toast.LENGTH_SHORT).show();
}
}
return data;
}
public void verification1 (View v)
{
String CIN =verifi.getText().toString();
String cin="12345";
if (CIN.equalsIgnoreCase(cin))
{
Toast.makeText(this,"mot CIN correct" ,Toast.LENGTH_SHORT).show();
}
else if(CIN.equals(" "))
{
Toast.makeText(this," inseret mot CIN " ,Toast.LENGTH_SHORT).show();
}
else
{ReadSettings(getBaseContext());
startActivity(new Intent(this,Principal.class));
Toast.makeText(this,"mot CIN incorrect" ,Toast.LENGTH_SHORT).show();
}}
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.verification1);
verifi=(EditText)findViewById(R.id.verification);
verification2=(Button)findViewById(R.id.verifier);
verification2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
verification1(verification2);
}
});
}} |
Partager