app/src/main/java/fi/finwe/orion360/sdk/pro/examples/MainMenu.java
private void checkWritePermissionAndCopyContent() {

		// Check permission status.
		int permission = ContextCompat.checkSelfPermission(this,
				Manifest.permission.WRITE_EXTERNAL_STORAGE);

		// If missing, check if we should first explain why it is needed, then request it.
		if (permission != PackageManager.PERMISSION_GRANTED) {

			if (ActivityCompat.shouldShowRequestPermissionRationale(this,
					Manifest.permission.WRITE_EXTERNAL_STORAGE)) {

				AlertDialog.Builder builder = new AlertDialog.Builder(this);
				builder.setMessage(R.string.main_menu_permission_request_write)
						.setTitle(R.string.main_menu_permission_request_title);
				builder.setPositiveButton(R.string.main_menu_permission_grant_button_label,
						new DialogInterface.OnClickListener() {
							public void onClick(DialogInterface dialog, int id) {
								requestWritePermission();
							}
						});
				AlertDialog dialog = builder.create();
				dialog.show();
			} else {
				requestWritePermission();
			}
		} else {

			// Permission is already granted, proceed to copy test content in place.
			copyTestContent(true);

		}
	}
/**
     * Check if write permission is granted, and if not, request it, and then copy the content.
     */
Check if write permission is granted, and if not, request it, and then copy the content.
Check if write permission is granted and if not request it and then copy the content .
private void checkWritePermissionAndCopyContent() {
		int permission = ContextCompat.checkSelfPermission(this,
				Manifest.permission.WRITE_EXTERNAL_STORAGE);
		if (permission != PackageManager.PERMISSION_GRANTED) {
			if (ActivityCompat.shouldShowRequestPermissionRationale(this,
					Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
				AlertDialog.Builder builder = new AlertDialog.Builder(this);
				builder.setMessage(R.string.main_menu_permission_request_write)
						.setTitle(R.string.main_menu_permission_request_title);
				builder.setPositiveButton(R.string.main_menu_permission_grant_button_label,
						new DialogInterface.OnClickListener() {
							public void onClick(DialogInterface dialog, int id) {
								requestWritePermission();
							}
						});
				AlertDialog dialog = builder.create();
				dialog.show();
			} else {
				requestWritePermission();
			}
		} else {
			copyTestContent(true);
		}
	}
private void checkWritePermissionAndCopyContent ( ) { int permission = ContextCompat . checkSelfPermission ( this , Manifest . permission . WRITE_EXTERNAL_STORAGE ) ; if ( permission != PackageManager . PERMISSION_GRANTED ) { if ( ActivityCompat . shouldShowRequestPermissionRationale ( this , Manifest . permission . WRITE_EXTERNAL_STORAGE ) ) { AlertDialog . Builder builder = new AlertDialog . Builder ( this ) ; builder . setMessage ( R . string . main_menu_permission_request_write ) . setTitle ( R . string . main_menu_permission_request_title ) ; builder . setPositiveButton ( R . string . main_menu_permission_grant_button_label , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int id ) { requestWritePermission ( ) ; } } ) ; AlertDialog dialog = builder . create ( ) ; dialog . show ( ) ; } else { requestWritePermission ( ) ; } } else { copyTestContent ( true ) ; } }
Check if write permission is granted, and if not, request it, and then copy the content.
Check if write permission is granted and if not request it and then copy the content .
// Check permission status. // If missing, check if we should first explain why it is needed, then request it. // Permission is already granted, proceed to copy test content in place.