· 8 years ago · Aug 31, 2018, 10:36 AM
1problem in closing an activity at launch in android
2super.onCreate(savedInstanceState);
3
4 db = openOrCreateDatabase("TestData.db", SQLiteDatabase.CREATE_IF_NECESSARY, null);
5db.setVersion(1);
6db.setLocale(Locale.getDefault());
7db.setLockingEnabled(true);
8final String CREATE_TABLE_COUNTRIES ="CREATE TABLE IF NOT EXISTS tbl_countries (id TEXT);";
9db.execSQL(CREATE_TABLE_COUNTRIES);
10ContentValues values = new ContentValues();
11 values.put("id", textvalue );
12 Cursor cx = db.rawQuery("select id from tbl_countries" , null);
13 counter=0;
14 if (cx != null )
15 {
16 if (cx.moveToFirst())
17 {
18 do
19 {
20 counter=counter+1;
21 }
22 while (cx.moveToNext());
23 }
24 }
25 db.close();
26
27if(counter == 0)
28{
29 setContentView(R.layout.main);
30 et = (EditText)findViewById(R.id.editText1);
31
32 textvalue = et.getText().toString();
33 b = (Button)findViewById(R.id.button1);
34 b.setOnClickListener(new View.OnClickListener()
35 {
36 @Override
37 public void onClick(View v)
38 {
39 Intent myIntent = new Intent(getBaseContext(), SeconDClass.class);
40 startActivityForResult(myIntent, 0);
41 finish();
42 }
43 });
44}
45else if(counter>=1)
46 {
47 Intent myIntent = new Intent(getBaseContext(), SeconDClass.class);
48 startActivityForResult(myIntent, 0);
49 finish();
50 }
51
52startActivityForResult(myIntent, 0);
53 finish();