-
-
Save anonymous/ca7896fd1c3709a84557 to your computer and use it in GitHub Desktop.
android
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
public ArrayList<String> getname(String group){ | |
if(group=="1") | |
str="dbtable1"; | |
SQLiteDatabase db = getReadableDatabase(); | |
String sql = "SELECT name FROM " + str + " WHERE confirm = 0" ; | |
Cursor cursor = db.rawQuery(sql,null); | |
ArrayList<String> name = new ArrayList<String>(); | |
int columnCount = cursor.getColumnCount(); | |
while(cursor.moveToNext()){ | |
String name_addr = ""; | |
for(int i=0; i<columnCount; i++) | |
name_addr += cursor.getString(i) + "\n"; | |
name.add(name_addr); | |
} | |
cursor.close(); | |
db.close(); | |
return name; | |
} |
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
private Button.OnClickListener listener2 = new Button.OnClickListener(){ | |
public void onClick(View v) { | |
StringBuilder name=new StringBuilder(""); | |
ArrayList<String> names = dbset.getname(group); | |
if(names.size()>0){ | |
for(String n: names) | |
name.append(n + "\n"); | |
}else{ | |
name.append("找不到"); | |
} | |
Toast.makeText(method.this, name, Toast.LENGTH_LONG).show(); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment