@SuppressWarnings("deprecation") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setAppName("survey"); setContentView(R.layout.place_name_dialog); mLoadButtonContainer = (RelativeLayout) findViewById(R.id.loadButtonContainer); mLoadImageButton = (ImageButton) findViewById(R.id.loadImageButton); mPurgeButtonContainer = (RelativeLayout) findViewById(R.id.prugeButtonContainer); mPurgeImageButton = (ImageButton) findViewById(R.id.purgeImageButton); mLoadPlaceTask = (LoadPlaceTask) getLastNonConfigurationInstance(); if (mLoadPlaceTask != null) { // setup dialog and upload task // showDialog(PROGRESS_DIALOG); // register this activity with the new loader task mLoadPlaceTask.setListener(PlaceListActivity.this); } else { mMessageTextView = (TextView) findViewById(R.id.messageTextView); File db_file = new File( ODKFileUtils.getPlaceNameDbFolder(getAppName()) + File.separator + PlaceNameDatabaseHelper.PLACE_NAME_DATABASE_NAME); if (db_file.exists() == false) { File csv_file = new File(ODKFileUtils.getPlaceNameCsvFile(getAppName())); if (csv_file.exists() == false) { mMessageTextView.setText( getString( R.string.unable_to_find_config_file, ODKFileUtils.getPlaceNameDbFolder(getAppName()))); disableButtons(); } } else { // Count place name list loaded in the database and prepare the // message // to display accordingly. long count = PlaceNameUtil.getCount(this); if (count == 0) { mMessageTextView.setText(R.string.load_place_list); } else if (count == 1) { mMessageTextView.setText(R.string.one_place_list); } else { /* * int resourceId = this.getResources().getIdentifier( * "many_place_list", "string", this.getPackageName()); */ mMessageTextView.setText(getString(R.string.many_place_list, String.valueOf(count))); // + this.getString(resourceId)); } } } }
public void purgeClickListener(View v) { SQLiteDatabase db = PlaceNameDatabaseFactory.get().getDatabase(PlaceListActivity.this, getAppName()); // clear place table PlaceNameUtil.delete(db); db.close(); mMessageTextView.setText(R.string.load_place_list); }