SQLite Connection leaked although everything closed

The bolded font in the citation corresponds to this part in your code: private DatabaseManager open() throws SQLException { dbHelper = new DatabaseHelper(context); db = dbHelper.getWritableDatabase(); from: http://www.androiddesignpatterns.com/2012/05/correctly-managing-your-sqlite-database.html Approach #1: Use an Abstract Factory to Instantiate the SQLiteOpenHelper Declare your database helper as a static instance variable and use the Abstract Factory pattern to guarantee … Read more

SQLite Database gives warning automatic index on (column) After upgrading Android L

Automatic indexing was introduced in sqlite 3.7.17. A version of sqlite with this feature was only included in Android L developer preview. This is why you get the message only on Lollipop but not earlier. Even if it is logged as an error, it’s really just a message. Basically, the automatic indexing comes into play … Read more

Inserting current date and time in SQLite database

SQLite supports the standard SQL variables CURRENT_DATE, CURRENT_TIME, and CURRENT_TIMESTAMP: INSERT INTO Date (LastModifiedTime) VALUES(CURRENT_TIMESTAMP) The default data type for dates/times in SQLite is TEXT. ContentValues do not allow to use generic SQL expressions, only fixed values, so you have to read the current time in Java: cv.put(“LastModifiedTime”, new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”).format(new Date()));

Best option to store username and password in android app

Yes, this is tricky on Android. You don’t want to store the plaintext password in the preferences, because anyone with a rooted device will basically be displaying their password to the world. On the flip side, you can’t use an encrypted password, because you’d have to store your encryption/decryption key somewhere on the device, again … Read more