私はアンドロイドを新しくしました。私はsqliteデータベースからのデータを使用してリストビューを作成する問題に直面している。私は連絡先データからリストビューを作成するには、以下のこのコードを見つけ Androidリストビュー
public class Test extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get a cursor with all people
Cursor c = getContentResolver().query(Contacts.CONTENT_URI,CONTACT_PROJECTION, null, null, null);
startManagingCursor(c);
ListAdapter adapter = new SimpleCursorAdapter(this,
// Use a template that displays a text view
android.R.layout.simple_list_item_1,
// Give the cursor to the list adatper
c,
// Map the NAME column in the people database to...
new String[] {Contacts.DISPLAY_NAME},
// The "text1" view defined in the XML template
new int[] {android.R.id.text1});
setListAdapter(adapter);
}
private static final String[] CONTACT_PROJECTION = new String[] {
Contacts._ID,
Contacts.DISPLAY_NAME
};
}
は今、私はので、私はデータを表示することができ、これらの2つのコードを組み合わせることができますどのようにデータベース今
SQLiteDatabase myDB= null;
String TableName = "myTable";
myDB = this.openOrCreateDatabase("DatabaseName", MODE_PRIVATE, null);
// Get a cursor with all people
Cursor c = myDB.rawQuery("SELECT * FROM " + TableName , null);
からデータを取得するためにこのコードを使用このリストのデータベースから取り出されます。
ありがとうございます。
次のチュートリアルのコードに従うことができます。その後、コードはどのようになりますか? –
その場合は、単にあなたの質問にデシベルのコードをコピーして、カーソルC = getcontentaresolver(...)を交換... – kosa
これを尋ねることは、ログファイル HTTPをチェックし、ここでその示すエラー をquestion.But前に、私はそれを試してみました: //polbd.com/log.txt –