Androidプログラミング質問スレ Part30
■ このスレッドは過去ログ倉庫に格納されています
0442デフォルトの名無しさん
2013/03/19(火) 22:23:11.78以下のようにしてCursorLoaderを使ってみたのですが、
---
private static final String[] COLUMNS = { "_id","date","eltime","distance","place" };
File dbPath = this.getDatabasePath( "hoge.db" );
Uri dbUri = Uri.fromFile(dbPath);
CursorLoader cl = new CursorLoader(this, dbUri, COLUMNS, null, null, "_id DESC");
cl.registerListener(1,
new OnLoadCompleteListener<Cursor>() {
@Override
public void onLoadComplete(Loader<Cursor> cl, Cursor cursor) {
// TODO Auto-generated method stub
showAll(cursor);
}
}
);
cl.startLoading();
---
匿名クラスのコールバックが呼ばれるのですが、cursor=nullになってしまいます。
UriをtoString()で表示すると、"file:///data/data/com.example.hoge/databases/hoge.db"になっています。
そこでググってみると、こんなページを発見
CursorLoader, get URI for local database
http://stackoverflow.com/questions/12485448/cursorloader-get-uri-for-local-database
> The reason behind cursor loader accepting a URI is that it expects to query a contentProvider and not a raw database.
コンテンツプロバイダーにしないと使えないと書かれているのですが、本当でしょうか?
よろしくお願い致します。
■ このスレッドは過去ログ倉庫に格納されています