Skip to content

Instantly share code, notes, and snippets.

@msdalp
Created March 1, 2014 19:25
Show Gist options
  • Save msdalp/9295644 to your computer and use it in GitHub Desktop.
Save msdalp/9295644 to your computer and use it in GitHub Desktop.
public synchronized String getDataValue(long _id) {
final SQLiteDatabase db = this.getReadableDatabase();
String retval = null;
try {
Cursor cursor = db.query("data", new String[]{"VALUE"},
"ID = ?", new String[]{String.valueOf(_id)}, null, null, null);
if (cursor != null) {
if (cursor.moveToFirst()) {
do {
retval = cursor.getString(0);
} while (cursor.moveToNext());
}
}
} catch (Exception ex) {
retval = null;
Log.e(TAG, "Cannot get data value:", ex);
} finally {
db.close();
}
return retval;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment