Share SQLite database between 2 android apps?

I need to share a single database between 2 apps. I know that the database will be created on /data/data/MY_PACKAGE/databases/ . Since the packages names are different is it possible to define the path to one package name when I create the database on either app? Thanks. Answer UPDATE: The method described below relies on … Read more

Set FAB (Floating Action Button) above keyboard

Already asked here but without a proper answer. I want the FAB to float on top of the keyboard. that’s it. For example Open a new Blank Activity template project with Android Studio Change the Hello World TextView to EditText See image below: Answer Turns out it’s pretty easy, Add android:windowSoftInputMode=”adjustResize” to your activity in … Read more

Best method to download image from url in Android

I’m using below method to download single image from url public static Bitmap getBitmap(String url) { try { InputStream is = (InputStream) new URL(url).getContent(); Bitmap d = BitmapFactory.decodeStream(is); is.close(); return d; } catch (Exception e) { return null; } } Sometimes I get an outofmemory exception. I am unable to catch outofmemory exception. The app … Read more

android: smoothScrollToPosition() not working correctly

I’m trying to smoothly scroll to last element of a list after adding an element to the arrayadapter associated with the listview. The problem is that it just scrolls to a random position arrayadapter.add(item); //DOES NOT WORK CORRECTLY: listview.smoothScrollToPosition(arrayadapter.getCount()-1); //WORKS JUST FINE: listview.setSelection(arrayadapter.getCount()-1); Answer You probably want to tell the ListView to post the scroll … Read more

Android: Get Hardware Information Programmatically

I have a requirement for obtaining the hardware related information on an Android device that runs my application. I need information of the following sort. CPU Manufacturer, model and serial number SD Card Manufacturer and serial number Camera Manufacturer and other related specs Bluetooth related hardware information WiFi related hardware information RAM Vendor / model … Read more