Created
February 26, 2012 10:44
-
-
Save philipesteiff/1916007 to your computer and use it in GitHub Desktop.
[Android] Banco de dados e consulta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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