DBHelper helper=new DBHelper(......)
SQLitedatebase db=helper.getReadabledatabase()
db.exe("select count as totalcount from tablename")
你说的是sqlite数据库吧,不应该叫android数据库。我来举个例你仿写就行:
SQLiteDatabase database = SQLiteDatabase.openOrCreateDatabase(databaseFilename, null)// 获得.db文件的绝对路径databaseFilename
String sql = "select score from list where id='10' "//list是你的表名
Cursor cursor = database.rawQuery(sql,new String[]{})
while(cursor.moveToNext())
{
int nameColumnIndex1 = cursor.getColumnIndex("score")
String strValue1=cursor.getString(nameColumnIndex1)
}
List<String>itemList = new ArrayList<String>()ListView.setAdapter(new ArrayAdapter<String>(Activity1.this,android.R.layout.simple_list_item_1,itemList))
只要每次跳回Activity1的时候,往容器itemList里添加数据就可以了
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)