List of usage examples for android.content SharedPreferences getLong
long getLong(String key, long defValue);
From source file:fr.openbike.android.service.SyncService.java
@SuppressWarnings("unchecked") @Override/*from www . ja v a2 s. co m*/ protected void onHandleIntent(Intent intent) { NetworkInfo activeNetwork = ((ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE)) .getActiveNetworkInfo(); final ResultReceiver receiver = intent.getParcelableExtra(EXTRA_STATUS_RECEIVER); Bundle bundle = new Bundle(); int status = STATUS_ERROR; if (activeNetwork == null || !activeNetwork.isConnectedOrConnecting()) { bundle = new Bundle(); bundle.putString(Intent.EXTRA_TEXT, "No network connectivity"); receiver.send(STATUS_ERROR, bundle); return; } String action = intent.getAction(); try { if (ACTION_SYNC.equals(action)) { if (receiver != null) { receiver.send(STATUS_SYNC_STATIONS, Bundle.EMPTY); } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); Object result = mRemoteExecutor.executeGet( mPreferences.getString(AbstractPreferencesActivity.UPDATE_SERVER_URL, "") + "/v2/stations", new RemoteStationsSyncHandler( prefs.getLong(AbstractPreferencesActivity.STATIONS_VERSION, 0)), this); if (result == null) { // Need stations update action = ACTION_UPDATE; } else { String message = (String) result; status = STATUS_SYNC_STATIONS_FINISHED; if (!"".equals(message)) { bundle.putString(EXTRA_RESULT, message); } prefs.edit().putLong(AbstractPreferencesActivity.LAST_UPDATE, System.currentTimeMillis()) .commit(); } } if (ACTION_UPDATE.equals(action)) { if (receiver != null) { receiver.send(STATUS_UPDATE_STATIONS, Bundle.EMPTY); } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); Object result = mRemoteExecutor .executeGet(mPreferences.getString(AbstractPreferencesActivity.UPDATE_SERVER_URL, "") + "/v2/stations/list", new RemoteStationsUpdateHandler(), this); status = STATUS_UPDATE_STATIONS_FINISHED; if (result != null) { bundle.putString(EXTRA_RESULT, (String) result); } prefs.edit().putLong(AbstractPreferencesActivity.LAST_UPDATE, System.currentTimeMillis()).commit(); } if (ACTION_CHOOSE_NETWORK.equals(action)) { if (receiver != null) { receiver.send(STATUS_SYNC_NETWORKS, Bundle.EMPTY); bundle = new Bundle(); bundle.putParcelableArrayList(EXTRA_RESULT, (ArrayList<Network>) mRemoteExecutor .executeGet(NETWORKS_URL, new RemoteNetworksHandler(), this)); status = STATUS_SYNC_NETWORKS_FINISHED; } } if (receiver != null) { receiver.send(status, bundle); } } catch (HandlerException e) { if (receiver != null) { // Pass back error to surface listener bundle = new Bundle(); bundle.putString(Intent.EXTRA_TEXT, e.toString()); receiver.send(STATUS_ERROR, bundle); } } catch (Exception e) { if (receiver != null) { // Pass back error to surface listener e.printStackTrace(); bundle = new Bundle(); bundle.putString(Intent.EXTRA_TEXT, "Une erreur est survenue. Veuillez ressayer."); receiver.send(STATUS_ERROR, bundle); } } }
From source file:com.notepadlite.NoteListFragment.java
@Override public void onResume() { super.onResume(); // Before we do anything else, check for a saved draft; if one exists, load it SharedPreferences prefMain = getActivity().getPreferences(Context.MODE_PRIVATE); if (getId() == R.id.noteViewEdit && prefMain.getLong("draft-name", 0) != 0) { Bundle bundle = new Bundle(); bundle.putString("filename", "draft"); Fragment fragment = new NoteEditFragment(); fragment.setArguments(bundle);//from w w w.j a v a 2s. c om // Add NoteEditFragment getFragmentManager().beginTransaction().replace(R.id.noteViewEdit, fragment, "NoteEditFragment") .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE).commit(); } else { if (getId() == R.id.noteViewEdit) { // Change window title String title = getResources().getString(R.string.app_name); getActivity().setTitle(title); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription(title, null, getResources().getColor(R.color.primary)); getActivity().setTaskDescription(taskDescription); } // Don't show the Up button in the action bar, and disable the button ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false); ((AppCompatActivity) getActivity()).getSupportActionBar().setHomeButtonEnabled(false); } // Read preferences SharedPreferences pref = getActivity() .getSharedPreferences(getActivity().getPackageName() + "_preferences", Context.MODE_PRIVATE); theme = pref.getString("theme", "light-sans"); sortBy = pref.getString("sort_by", "date"); showDate = pref.getBoolean("show_date", false); directEdit = pref.getBoolean("direct_edit", false); // Apply theme LinearLayout noteViewEdit = (LinearLayout) getActivity().findViewById(R.id.noteViewEdit); LinearLayout noteList = (LinearLayout) getActivity().findViewById(R.id.noteList); if (theme.contains("light")) { noteViewEdit.setBackgroundColor(getResources().getColor(R.color.window_background)); noteList.setBackgroundColor(getResources().getColor(R.color.window_background)); } if (theme.contains("dark")) { noteViewEdit.setBackgroundColor(getResources().getColor(R.color.window_background_dark)); noteList.setBackgroundColor(getResources().getColor(R.color.window_background_dark)); } // Refresh list of notes onResume (instead of onCreate) to reflect additions/deletions and preference changes listNotes(); } }
From source file:com.adwhirl.AdWhirlManager.java
public void fetchConfig() { Context context = contextReference.get(); // If the context is null here something went wrong with initialization. if (context == null) { return;// w w w . ja v a 2s . c o m } SharedPreferences adWhirlPrefs = context.getSharedPreferences(keyAdWhirl, Context.MODE_PRIVATE); String jsonString = adWhirlPrefs.getString(PREFS_STRING_CONFIG, null); long timestamp = adWhirlPrefs.getLong(PREFS_STRING_TIMESTAMP, -1); Log.d(AdWhirlUtil.ADWHIRL, "Prefs{" + keyAdWhirl + "}: {\"" + PREFS_STRING_CONFIG + "\": \"" + jsonString + "\", \"" + PREFS_STRING_TIMESTAMP + "\": " + timestamp + "}"); if (jsonString == null || configExpireTimeout == -1 || System.currentTimeMillis() >= timestamp + configExpireTimeout) { Log.i(AdWhirlUtil.ADWHIRL, "Stored config info not present or expired, fetching fresh data"); HttpClient httpClient = new DefaultHttpClient(); String url = String.format(AdWhirlUtil.urlConfig, this.keyAdWhirl, AdWhirlUtil.VERSION); HttpGet httpGet = new HttpGet(url); HttpResponse httpResponse; try { httpResponse = httpClient.execute(httpGet); Log.d(AdWhirlUtil.ADWHIRL, httpResponse.getStatusLine().toString()); HttpEntity entity = httpResponse.getEntity(); if (entity != null) { InputStream inputStream = entity.getContent(); jsonString = convertStreamToString(inputStream); SharedPreferences.Editor editor = adWhirlPrefs.edit(); editor.putString(PREFS_STRING_CONFIG, jsonString); editor.putLong(PREFS_STRING_TIMESTAMP, System.currentTimeMillis()); editor.commit(); } } catch (ClientProtocolException e) { Log.e(AdWhirlUtil.ADWHIRL, "Caught ClientProtocolException in fetchConfig()", e); } catch (IOException e) { Log.e(AdWhirlUtil.ADWHIRL, "Caught IOException in fetchConfig()", e); } } else { Log.i(AdWhirlUtil.ADWHIRL, "Using stored config data"); } parseConfigurationString(jsonString); }
From source file:edu.usf.cutr.opentripplanner.android.tasks.ServerSelector.java
protected void onPostExecute(Long result) { if ((activity.get() != null) && showDialog) { try {/*from w w w. j a v a 2 s.c om*/ if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); } } catch (Exception e) { Log.e(TAG, "Error in Server Selector PostExecute dismissing dialog: " + e); } } if (selectedServer != null) { //We've already auto-selected a server SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences(context.getApplicationContext()); long serverId = prefs.getLong(OTPApp.PREFERENCE_KEY_SELECTED_SERVER, 0); Server s = null; boolean serverIsChanged = true; if (serverId != 0) { dataSource.open(); s = dataSource.getServer(prefs.getLong(OTPApp.PREFERENCE_KEY_SELECTED_SERVER, 0)); dataSource.close(); } if (s != null) { serverIsChanged = !(s.getRegion().equals(selectedServer.getRegion())); } if (showDialog || serverIsChanged) { Toast.makeText(context.getApplicationContext(), context.getResources().getString(R.string.server_selector_detected) + " " + selectedServer.getRegion() + ". " + context.getResources().getString(R.string.server_selector_server_change_info), Toast.LENGTH_SHORT).show(); } Editor e = prefs.edit(); e.putLong(PREFERENCE_KEY_SELECTED_SERVER, selectedServer.getId()); e.putBoolean(PREFERENCE_KEY_SELECTED_CUSTOM_SERVER, false); e.commit(); callback.onServerSelectorComplete(selectedServer); } else if (knownServers != null && !knownServers.isEmpty()) { Log.d(TAG, "No server automatically selected. User will need to choose the OTP server."); // Create dialog for user to choose List<String> serverNames = new ArrayList<String>(); for (Server server : knownServers) { serverNames.add(server.getRegion()); } Collections.sort(serverNames); serverNames.add(0, context.getResources().getString(R.string.custom_server_name)); final CharSequence[] items = serverNames.toArray(new CharSequence[serverNames.size()]); if (activity.get() != null) { String actualCustomServer = "http://itract.cs.kau.se:8081/proxy/api/otp/ws"; ServerChecker serverChecker = new ServerChecker(activity, context, ServerSelector.this, false); serverChecker.execute(new Server(actualCustomServer, context)); /*AlertDialog.Builder builder = new AlertDialog.Builder(activity.get() ); builder.setTitle(context.getResources().getString(R.string.server_selector_server_info_dialog_title)); builder.setItems(items, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { //If the user selected to enter a custom URL, they are shown this EditText box to enter it if(items[item].equals(context.getResources().getString(R.string.custom_server_name))) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()); final EditText tbBaseURL = new EditText(activity.get()); String actualCustomServer = "http://itract.cs.kau.se:8081/proxy/api/otp/ws";//prefs.getString(PREFERENCE_KEY_CUSTOM_SERVER_URL, ""); tbBaseURL.setText(actualCustomServer); AlertDialog.Builder urlAlert = new AlertDialog.Builder(activity.get()); urlAlert.setTitle(context.getResources().getString(R.string.server_selector_custom_server_alert_title)); urlAlert.setView(tbBaseURL); urlAlert.setPositiveButton(context.getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = tbBaseURL.getText().toString().trim(); if (URLUtil.isValidUrl(value)){ SharedPreferences.Editor prefsEditor = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()).edit(); prefsEditor.putString(PREFERENCE_KEY_CUSTOM_SERVER_URL, value); ServerChecker serverChecker = new ServerChecker(activity, context, ServerSelector.this, false); serverChecker.execute(new Server(value, context)); prefsEditor.commit(); } else{ Toast.makeText(context, context.getResources().getString(R.string.custom_server_url_error), Toast.LENGTH_SHORT).show(); } } }); selectedCustomServer = true; urlAlert.create().show(); } else { //User picked server from the list for (Server server : knownServers) { //If this server region matches what the user picked, then set the server as the selected server if (server.getRegion().equals(items[item])) { selectedServer = server; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()); Editor e = prefs.edit(); e.putLong(PREFERENCE_KEY_SELECTED_SERVER, selectedServer.getId()); e.putBoolean(PREFERENCE_KEY_SELECTED_CUSTOM_SERVER, false); e.commit(); callback.onServerSelectorComplete(selectedServer); break; } } } Log.v(TAG, "Chosen: " + items[item]); } }); builder.show();*/ } } else { //TODO - handle error here that server list cannot be loaded Log.e(TAG, "Server list could not be downloaded!!"); } }
From source file:com.anjalimacwan.fragment.NoteListFragment.java
@Override public void onResume() { super.onResume(); // Before we do anything else, check for a saved draft; if one exists, load it SharedPreferences prefMain = getActivity().getPreferences(Context.MODE_PRIVATE); if (getId() == R.id.noteViewEdit && prefMain.getLong("draft-name", 0) != 0) { Bundle bundle = new Bundle(); bundle.putString("filename", "draft"); Fragment fragment = new NoteEditFragment(); fragment.setArguments(bundle);/* w w w . j av a2s . c o m*/ // Add NoteEditFragment getFragmentManager().beginTransaction().replace(R.id.noteViewEdit, fragment, "NoteEditFragment") .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE).commit(); } else { if (getId() == R.id.noteViewEdit) { // Change window title String title = getResources().getString(R.string.app_name); getActivity().setTitle(title); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription(title, null, ContextCompat.getColor(getActivity(), R.color.primary)); getActivity().setTaskDescription(taskDescription); } // Don't show the Up button in the action bar, and disable the button ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false); ((AppCompatActivity) getActivity()).getSupportActionBar().setHomeButtonEnabled(false); } // Read preferences SharedPreferences pref = getActivity() .getSharedPreferences(getActivity().getPackageName() + "_preferences", Context.MODE_PRIVATE); theme = pref.getString("theme", "light-sans"); sortBy = pref.getString("sort_by", "date"); showDate = pref.getBoolean("show_date", false); directEdit = pref.getBoolean("direct_edit", false); // Apply theme LinearLayout noteViewEdit = (LinearLayout) getActivity().findViewById(R.id.noteViewEdit); LinearLayout noteList = (LinearLayout) getActivity().findViewById(R.id.noteList); if (theme.contains("light")) { noteViewEdit.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background)); noteList.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background)); } if (theme.contains("dark")) { noteViewEdit .setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background_dark)); noteList.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background_dark)); } // Refresh list of notes onResume (instead of onCreate) to reflect additions/deletions and preference changes listNotes(); } }
From source file:ru.orangesoftware.financisto.activity.FlowzrSyncActivity.java
protected void restoreUIFromPref() { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); lastSyncLocalTimestamp = MyPreferences.getFlowzrLastSync(getApplicationContext()); preferences.getLong(FlowzrSyncOptions.PROPERTY_LAST_SYNC_TIMESTAMP, 0); AccountManager accountManager = AccountManager.get(getApplicationContext()); Account[] accounts = accountManager.getAccountsByType("com.google"); for (Account account : accounts) { if (preferences.getString(FlowzrSyncOptions.PROPERTY_USE_CREDENTIAL, "").equals(account.name)) { useCredential = account;/* w ww . ja va2 s . c o m*/ } } TextView tv = (TextView) findViewById(R.id.sync_was); tv.setText(getString(R.string.flowzr_sync_was) + " " + new Date(lastSyncLocalTimestamp).toLocaleString()); }
From source file:it.baywaylabs.jumpersumo.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Testing/* ww w .j a v a2 s. c o m*/ // String bella = "Hello, it's me. Can you turn left and go on and turn right and go left ancora and take photo va?"; String bella = "hello can go on and execute http://www.baywaylabs.it/tesi/commands.txt"; Finder f = new Finder(); PriorityQueue pq = f.processingMessage(bella); /* while(!pq.isEmpty()) { Log.e(TAG, ((Command)pq.peek()).getCmd() ); pq.remove(); } */ List<String> prova = f.getStringQueue(pq); for (String s : prova) { Log.e(TAG, "Stringa: " + s); } File folder = new File(Constants.DIR_ROBOT); FileFilter ff = new FileFilter(); File[] list = folder.listFiles(ff); Log.e(TAG, "Lista file: " + list.length); for (int p = 0; p < list.length; p++) Log.e(TAG, "Nome file: " + list[p].getName()); String urlReal = f.getUrls(bella).get(0); Log.e(TAG, "Url Stringa numero 1: " + urlReal); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.HelloOpenCvView); // mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE); mOpenCvCameraView.setCvCameraViewListener(MainActivity.this); // End Testing SharedPreferences sharedPref = MainActivity.this.getSharedPreferences(Constants.MY_PREFERENCES, Context.MODE_PRIVATE); Log.d(TAG, "Vediamo se ho memorizzato bene: " + sharedPref.getLong(Constants.LAST_ID_MENTIONED, 0)); initBroadcastReceiver(); initServiceConnection(); listView = (ListView) findViewById(R.id.list); deviceList = new ArrayList<ARDiscoveryDeviceService>(); deviceNameList = new String[] {}; Log.d(TAG, "DEVICES: " + deviceList.toString()); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.row, R.id.textViewList, deviceNameList); adapter.notifyDataSetChanged(); // Assign adapter to ListView listView.setAdapter(adapter); //ListView Item Click Listener listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ARDiscoveryDeviceService service = deviceList.get(position); Intent intent = new Intent(MainActivity.this, PilotingActivity.class); intent.putExtra(PilotingActivity.EXTRA_DEVICE_SERVICE, service); startActivity(intent); } }); }
From source file:com.numenta.taurus.service.TaurusNotificationService.java
/** * Check if we need to fire new notifications based on the current application data and state *///from w w w. j av a 2s.c o m protected void synchronizeNotifications() throws HTMException, IOException { Context context = getService().getApplicationContext(); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); // Check if the notifications are enabled boolean enable = prefs.getBoolean(PREF_NOTIFICATIONS_ENABLE, true); if (enable) { final long now = System.currentTimeMillis(); // Get last time we checked for notifications final long lastRunTime = DataUtils .floorTo60minutes(prefs.getLong(PREF_NOTIFICATION_LAST_RUN_TIME, now)); prefs.edit().putLong(PREF_NOTIFICATION_LAST_RUN_TIME, now).apply(); // Get user frequency preference final long frequency = Long.parseLong(prefs.getString(PREF_NOTIFICATIONS_FREQUENCY, "0")) * 1000; // Check for pending notifications since last time List<Notification> notifications = getPendingNotifications(lastRunTime, now, frequency); if (notifications.isEmpty()) { // No new notifications return; } // Build notification based on user settings NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context) .setOnlyAlertOnce(true).setSmallIcon(com.numenta.core.R.drawable.ic_launcher) .setAutoCancel(true); // Get notifications ringtone String ringUrlStr = prefs.getString(PREF_NOTIFICATIONS_RINGTONE, null); if (ringUrlStr != null && !ringUrlStr.trim().isEmpty()) { notificationBuilder.setSound(Uri.parse(ringUrlStr)); } // Check if we should vibrate if (prefs.getBoolean(PREF_NOTIFICATIONS_VIBRATE, false)) { notificationBuilder.setDefaults(NotificationCompat.DEFAULT_VIBRATE); notificationBuilder.setVibrate(new long[] { 1000l }); } // Fire new notifications NotificationUtils.createGroupedOsNotification(notificationBuilder, notifications, false); // Update notification times for (Notification notification : notifications) { TaurusApplication.setLastNotificationTime(notification.getInstanceId(), notification.getTimestamp()); } } fireNotificationChangedEvent(getService()); }
From source file:com.brewcrewfoo.performance.fragments.Tools.java
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (key.equals(RESIDUAL_FILES)) { mResidualFiles.setSummary(""); final long mStartTime = sharedPreferences.getLong(key, 0); if (mStartTime > 0) mResidualFiles.setSummary(DateUtils.getRelativeTimeSpanString(mStartTime)); } else if (key.equals(PREF_OPTIM_DB)) { mOptimDB.setSummary(""); final long mStartTime = sharedPreferences.getLong(key, 0); if (mStartTime > 0) mOptimDB.setSummary(DateUtils.getRelativeTimeSpanString(mStartTime)); }//ww w.j av a 2s . co m }
From source file:com.ternup.caddisfly.fragment.ResultFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); getActivity().setTitle(R.string.result); mContext = getActivity();// w w w .j a v a 2s . com mPpmText = (TextView) view.findViewById(R.id.ppmText); mDateView = (TextView) view.findViewById(R.id.testDate); mTitleView = (TextView) view.findViewById(R.id.titleView); mResultTextView = (TextView) view.findViewById(R.id.result); //mResultIcon = (ImageView) view.findViewById(R.id.resultIcon); mAddressText = (TextView) view.findViewById(R.id.address1); mAddress2Text = (TextView) view.findViewById(R.id.address2); mAddress3Text = (TextView) view.findViewById(R.id.address3); mSourceText = (TextView) view.findViewById(R.id.sourceType); ListView drawerList = (ListView) getActivity().findViewById(R.id.navigation_drawer); drawerList.setItemChecked(-1, true); drawerList.setSelection(-1); folderName = getArguments().getString(PreferencesHelper.FOLDER_NAME_KEY); mId = getArguments().getLong(getString(R.string.currentTestId)); final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext); mLocationId = sharedPreferences.getLong(getString(R.string.currentLocationId), -1); /*Button deleteButton = (Button) view.findViewById(R.id.deleteButton); deleteButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { AlertUtils.askQuestion(getActivity(), R.string.delete, R.string.areYouSure, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { FileUtils.deleteFolder(getActivity(), mLocationId, folderName); Uri uri = ContentUris .withAppendedId(TestContentProvider.CONTENT_URI, mId); mContext.getContentResolver().delete(uri, null, null); int value = 0; int counter = 0; SharedPreferences.Editor editor = sharedPreferences.edit(); while (value != -1) { value = sharedPreferences .getInt(String.format("result_%d_%d", mId, counter), -1); if (value > -1) { editor.remove(String.format("result_%d_%d", mId, counter)); editor.commit(); counter++; } } goBack(); } }, null ); } }); Button sendButton = (Button) view.findViewById(R.id.sendButton); sendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (NetworkUtils.checkInternetConnection(mContext)) { if (progressDialog == null) { progressDialog = new ProgressDialog(getActivity()); progressDialog.setMessage("Sending..."); progressDialog.setCancelable(false); } progressDialog.show(); postResult("testresults"); } } }); */ ArrayList<String> filePaths = FileUtils.getFilePaths(getActivity(), folderName, mLocationId); File directory = new File(FileUtils.getStoragePath(getActivity(), mLocationId, folderName, false)); if (!directory.exists()) { Uri uri = ContentUris.withAppendedId(TestContentProvider.CONTENT_URI, mId); mContext.getContentResolver().delete(uri, null, null); goBack(); } else if (filePaths.size() > 0) { displayResult(); } else { FileUtils.deleteFolder(getActivity(), mLocationId, folderName); } }