Skip to content

Instantly share code, notes, and snippets.

@philipesteiff
Created February 26, 2012 10:44
Show Gist options
  • Save philipesteiff/1916007 to your computer and use it in GitHub Desktop.
Save philipesteiff/1916007 to your computer and use it in GitHub Desktop.
[Android] Banco de dados e consulta
// BANCO DE DADOS
SQLiteDatabase db;
String path = Environment.getExternalStorageDirectory().toString();
db = openOrCreateDatabase(path + "/path/to/db.sqlite", SQLiteDatabase.CREATE_IF_NECESSARY, null);
Log.d("Debug", "Its open? " + db.isOpen());
String[] cols = {"colum1","colum2"};
Cursor c = db.query("table", cols, null, null, null, null, null);
while(c.moveToNext()){
Log.d("Debug", "Colum1: " + c.getInt(0));
Log.d("Debug", "Colum2: " + c.getString(1));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment