データベースからアプリへのレコードの数を整数で取得して表示したい...どうすればいいですか???
私はそうすることができません
ここにデータベースコードがあります
public int counttable()
{
int count=0;
openOrCreateDatabase();
count=db.execSQL("select count(*) from "+TableNameis+";");
return count;
}
データ型が一致しないことはわかっています...どうすればよいか誰か提案してもらえますか?? 整数変数にカウント値を格納する方法を教えてください。
ダッシュボード.java
public class Dashboard extends Activity {
EditText edt_pending, edt_completed,edt_synched;
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.dashboard);
edt_pending=(EditText)findViewById(R.id.editpending);
edt_completed=(EditText)findViewById(R.id.editcompleted);
edt_synched=(EditText)findViewById(R.id.editsynched);
WayDataBase way=new WayDataBase(Dashboard.this);
int count=way.counttable();
edt_completed.setText(count);
}
}
ログキャット
04-08 07:15:02.216: E/AndroidRuntime(16026): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.lthomepage/com.android.lthomepage.Dashboard}: android.content.res.Resources$NotFoundException: String resource ID #0x1
04-08 07:15:02.216: E/AndroidRuntime(16026): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
04-08 07:15:02.216: E/AndroidRuntime(16026): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
04-08 07:15:02.216: E/AndroidRuntime(16026): at android.app.ActivityThread.access$600(ActivityThread.java:141)
04-08 07:15:02.216: E/AndroidRuntime(16026): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
04-08 07:15:02.216: E/AndroidRuntime(16026): at android.os.Handler.dispatchMessage(Handler.java:99)
04-08 07:15:02.216: E/AndroidRuntime(16026): at android.os.Looper.loop(Looper.java:137)
04-08 07:15:02.216: E/AndroidRuntime(16026): at android.app.ActivityThread.main(ActivityThread.java:5039)
04-08 07:15:02.216: E/AndroidRuntime(16026): at java.lang.reflect.Method.invokeNative(Native Method)
04-08 07:15:02.216: E/AndroidRuntime(16026): at java.lang.reflect.Method.invoke(Method.java:511)
04-08 07:15:02.216: E/AndroidRuntime(16026): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-08 07:15:02.216: E/AndroidRuntime(16026): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-08 07:15:02.216: E/AndroidRuntime(16026): at dalvik.system.NativeStart.main(Native Method)
04-08 07:15:02.216: E/AndroidRuntime(16026): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x1
04-08 07:15:02.216: E/AndroidRuntime(16026): at android.content.res.Resources.getText(Resources.java:230)
04-08 07:15:02.216: E/AndroidRuntime(16026): at android.widget.TextView.setText(TextView.java:3640)
04-08 07:15:02.216: E/AndroidRuntime(16026): at com.android.lthomepage.Dashboard.onCreate(Dashboard.java:27)
04-08 07:15:02.216: E/AndroidRuntime(16026): at android.app.Activity.performCreate(Activity.java:5104)
04-08 07:15:02.216: E/AndroidRuntime(16026): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
04-08 07:15:02.216: E/AndroidRuntime(16026): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)