Posts

Showing posts from May, 2014

Export the SQLITEDB into .csv or .pdf

If you want to export the sqlite db into .csv  or .pdf. You are going use the following libraries OPENCSV-2.3.jar iTextPDF – 5.2.1.jar Task of Creating CSV public class ExportCSVTask extends AsyncTask<String, Void, Boolean> {            private final ProgressDialog dialog = new ProgressDialog(                      MainActivity.this);            protected void onPreExecute() {                 this.dialog.setMessage("Exporting database...");                 this.dialog.show();            }            @Override            protected Boolean doInBackground(String... params) {                 File dbFile = getDatabasePath("basic_db");                 File exportDB = new File(Environment.getExternalStorageDirectory(),                            "");                 if (!exportDB.exists()) {                      exportDB.mkdirs();                 }                 File file = new File(exportDB, getDateTime()

Link the TextView without using webview

Java TextView link; link = (TextView) findViewById(R.id.link); link.setMovementMethod(LinkMovementMethod.getInstance()); Strings.xml <string name="link_google"><u><a href="http://google.co.in">Go to Google</a></u></string> mainActivity.xml <TextView         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:textColor="#80BFFF"         android:text="@string/link_google"         android:id="@+id/link"         android:layout_gravity="center_vertical"         />

Split the String in android programming

If you are splitting the string value, you just use the method, public String splitString(String s) {          return new LinkedHashSet<String>(Arrays.asList(s.split(", "))).toString().replaceAll("(^\\[|\\]$)", "").replace(",", ", ");      } Reference: LinkedHashSet

Identify app is installed in the device

If you want to know the other app is installed or not, just using PackageManager . public boolean appInstalledOrNot(String uri) { PackageManager pm = getPackageManager(); boolean app_installed = false; try { pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES); app_installed = true; } catch (PackageManager.NameNotFoundException e) { app_installed = false; } return app_installed; } String uri means package name like com.example.app.  if(appInstalledOrNot(com.example.app)==false){ <-- app is not installed--> } else{ <-- app is installed--> }