Reputation: 566
I have programmed an app that accesses an SQLite database on the external storage. The app worked fine with Android 4.4 on my Nexus 4 and the emulator. Since I upgraded my phone to Android 5, it no longer shows any data from the SQLite database. The emulator on API 21 also shows no data.
There are no errors or exceptions thrown. The database cursor is simply empty on API 21.
The database is opened like this:
String path = myContext.getExternalFilesDir(null).getAbsolutePath() + File.separator + DB_NAME;
myDataBase = SQLiteDatabase.openDatabase(path, null, SQLiteDatabase.OPEN_READWRITE);
The query is executed like this:
Cursor cur = myDataBase.rawQuery("SELECT * FROM employee WHERE employee match ? " +
"ORDER BY firstname, lastname LIMIT 100",
new String[] { "*" + queryString+ "*" });
while (cur.moveToNext()) {
persons.add(getPerson(cur)); // never reaches this since API 21
}
cur.close();
What has changed from 18 to 21?
The full source code can be found here: https://github.com/sebastianhaeni/Contacts
Upvotes: 2
Views: 735
Reputation: 566
SQLite MATCH in Android 5 does not work the same way as it did in Android <= 4.4
The prefixed '*' was simply ignored before 5.0. Since 5.0 it searches a string beginning with '*'. Wildcards can only be used as a suffix.
Upvotes: 2