Tech Programming Ideas is one of the best places on the programming for programmers. Learn coding with Tech Programming Ideas tutorials. We are covered android programming, php, yii2 framework, javascript, mysql, vb.net etc.
//This is the file we are going to download. //Please add your server file location .
URL url = new URL("http://www.mission2win.in/pdf/pdf22.pdf");
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
//set path where to save the file
File SDCardRoot = Environment.getExternalStorageDirectory();
//create a new file to save
File file = new File(SDCardRoot,"pdf22.pdf");
FileOutputStream fileOutput = new FileOutputStream(file);
//stream used for reading the data from the internet
InputStream inputStream = urlConnection.getInputStream();
//create a buffer
byte[] buffer = new byte[124];
int bufferLength = 0;
Verify permission and add this code to give a permission
public static void verifyStoragePermissions(Activity activity) {
// Check if we have write permission
int permission = ActivityCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (permission != PackageManager.PERMISSION_GRANTED) {
// We don't have permission so prompt the user
ActivityCompat.requestPermissions(
activity,
PERMISSIONS_STORAGE,
REQUEST_EXTERNAL_STORAGE
);
}
}
Other wise add several permission to Manifest file.
<!-- Permission required for Downloading Files -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Permission required for Checking Internet Connection -->
//set path where to save the file
File SDCardRoot = Environment.getExternalStorageDirectory();
//create a new file to save
File file = new File(SDCardRoot,"pdf22.pdf");
FileOutputStream fileOutput = new FileOutputStream(file);
//stream used for reading the data from the internet
InputStream inputStream = urlConnection.getInputStream();
//This is total size of the downloading file totalSize = urlConnection.getContentLength(); runOnUiThread(new Runnable() { @Override public void run() { progressBar.setMax(totalSize); } });
//create a buffer
byte[] buffer = new byte[124];
int bufferLength = 0;
LibreOffice is a powerful and free office suite, used by millions of people around the world. LibreOffice includes several applications that make it the most versatile Free and Open Source office suite on the market: Writer (word processing), Calc (spreadsheets), Impress (presentations), Draw (vector graphics and flowcharts), Base (databases), and Math (formula editing).
The following steps show how to install VLC Media Player using the terminal on Unbutu. Open terminal window In the terminal – run the following command to refresh the software repository catalogue
sudo apt-get update
sudo apt-get install vlc
When prompted with the install size and ‘Do you want to continue’ press ‘Y’ on your keyboard.
This is simple example for data export to excel from PHP or HTML file using java script. It is very useful for web application developers.
Let's try this
Create studentlist.php or studentlist.html file
<html>
<head>
<title>Export to excel</title>
<Script>
function exportExcel(){ var tableID = "studentslist"; var filename = "student_list.xls"; var downloadLink; var dataType = 'application/vnd.ms-excel'; var tableSelect = document.getElementById(tableID); var tableHTML = tableSelect.outerHTML.replace(/ /g, '%20'); // Create download link element downloadLink = document.createElement("a"); document.body.appendChild(downloadLink); if(navigator.msSaveOrOpenBlob){ var blob = new Blob(['\ufeff', tableHTML], { type: dataType }); navigator.msSaveOrOpenBlob( blob, filename); }else{ // Create a link to the file downloadLink.href = 'data:' + dataType + ', ' + tableHTML; // Setting the file name downloadLink.download = filename; //triggering the function downloadLink.click(); } }
A view is simply a web page, or a page fragment, like a header, footer, sidebar, etc. In fact, views can flexibly be embedded within other views (within other views, etc., etc.) if you need this type of hierarchy.
Views are never called directly, they must be loaded by a controller. Remember that in an MVC framework, the Controller acts as the traffic cop, so it is responsible for fetching a particular view. If you have not read the Controllers page you should do so before continuing.
Creating a View
Using your text editor, create a file called blogview.php, and put this in it:
Then save the file in your application/views/ directory.
Loading a View
To load a particular view file you will use the following method:
$this->load->view('name');
Adding Dynamic Data to the View
Data is passed from the controller to the view by way of an array or an object in the second parameter of the view loading method. Here is an example using an array: