How to open pdf file programmatically in android ?


1. create assets folder in src under your app name.

2. In this assets folder keep your pdf files  e.g. schedule1.pdf.

3 now come your activity i.e

4. setListener on any UI component what you want i.e (Button,ImageView,ImageButton);

5. In this listener call one user defined method i.e. openPDFFiles();

the openPDFFiles() method have below code:—-

private void openPDFFiles()

AssetManager assetManager = getAssets();

InputStream in = null;
OutputStream out = null;
File file = new File(getFilesDir(), “schedule1.pdf”);//here schedule1.pdf is the pdf file name which is keep in assets folder.
try {
in =“schedule1.pdf”);
out = openFileOutput(file.getName(), Context.MODE_WORLD_READABLE);

copyFile(in, out);
in = null;
out = null;
} catch (Exception e) {
Log.e(“tag”, e.getMessage());

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(“file://” + getFilesDir() + “/schedule1.pdf”), “application/pdf”);


private void copyFile(InputStream in, OutputStream out) throws IOException

byte[] buffer = new byte[1024];
int read;
while ((read = != -1)

out.write(buffer, 0, read);


5 killer features of Android Studio


As Android platform continues to overtake the global mobile market in terms of number of devices, many developers are interested to adopt new software development tools that would allow them to thrive in this market. Android studio is a powerful IDE (integrated development environment) created in 2013 specifically for this purpose by Google, which makes it one of top choices alongside Eclipse in this field. Developers who are just now discovering Android Studio will be pleased to find out this IDE is loaded with advanced, developer-friendly options, such as:

Real-time coding and bug fixing

With Android Studio, development process is like shaping wet clay – whatever you do becomes automatically palpable. In the heart of technology that makes this possible is a high-quality code editor, of course, based on famous InteliJ IDEA editor. In practice, the editor is noted for smart editing and advanced code refactoring, while real-time rendering allows developers to see consequences of their actions immediately.

Of course, this makes bug fixing much easier since any faulty section of code will be easily identified. Alternative solutions to persistent problems can be sought in a more direct way, while the developer can get a feel for user perspective much easier. More subtle errors can also be discovered with deep static code analyses, uncovering impossible values of the variables and similar mishaps before they make any impact on the app.

Improved Developer Console

Google made sure that the developer console of Android Studio is packed with practical and smart features that make app building easier. Optimization is now handled very easily through a separate section that automatically displays professional tips, while Google Analytics is already integrated. With great visualization tools available for representing revenue graphs and access to quick translation services and ad campaign monitoring, all ingredients are in place for perfect overview of the entire development roadmap.

Taken together, these improvements allow developers to control different aspects of app performance from a single screen, helping to save time and prevent accidental oversights. In the right hands, that can be enough to make a difference and empower faster turnout of high-value applications that can be phased into the market in regular intervals.

Direct access to Google services

As a native IDE designed for Google’s ecosystem, Android Studio enjoys benefits ofcompatibility with other Google-branded products. This is a big selling point for the package that can’t be easily matched by competitors, and a big part of the explanation why Android Studio gained so many converts in such a short time.

Elementary cloud-based functions such as Google Cloud Messaging are now available directly from the IDE, eliminating a few boring steps in the process. For more ambitious users, smart plug-ins can be added to the mix, for example ADT Translation Manager which harnesses Google’s huge international experience to accelerate the app localization process. It makes sense to play the game Google’s way if your intention is to forge a niche market for your company on the Android platform and Android Studio is a perfect pathway in that direction.

Template-based wizards

One of the most important updates that appeared in the Android Studio 0.6.1. version concerns wizards used to create and manage activities within mobile projects. In addition to revamped visual look, the wizard has some improved functions and brings new SDK version dialogue. This tool helps developer choose which API level to target by displaying info about Android version name and number, cumulative distribution and various API’s present. Compatibility can also be ensured with improved lint checks, while this version eliminates several minor bugs present in the original IDE.

The activity wizard brings a lot of convenience to the table as well, introducing templates for most commonly used elements. Sure, it may take some time for newcomers to Android Studio to become familiar with the new wizard, but the end result will be well worth the effort.

Rich layout editor

Great developers need freedom to work and Android Studio respects this tendency. In this IDE, all UI elements can be simply dragged and dropped as various ideas are conceived and tested, creating perfect environment for an experimental mindset. To make things even better, layouts can be simply previewed for various screen specifications, providing cross-platform consistency from the earliest stages of layout design.