public String getInfromation(int id) {
myDataBase = this.getReadableDatabase();
String selection = "_id = ?";
String[] selectionArgs = new String[]{String.valueOf(id)};
Cursor cursor = myDataBase.query(TABLE_NAME , null , selection , selectionArgs , null , null , null);
String str = null;
if(cursor.moveToFirst() && cursor.getCount() >= 1) {
do {
str = cursor.getString(cursor.getColumnIndexOrThrow("mushroom"));
} while (cursor.moveToNext());
}
myDataBase.close();
return str;
}
package com,example.bd;
import android.app.Activity;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
import java.io.IOException;
import java.sql.SQLException;
public class Information extends Activity {
int id =0;
public TextView textView;
private DataBaseHelper db;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.information);
db = new DataBaseHelper(this);
String item = getIntent().getExtras().getString("title");
id = getIntent().getExtras().getInt("id", 0);
textView = (TextView) findViewById(R.id.textView1);
db.getInfromation(id);
}
public Cursor getInfromation(int id) {
String selection = "_id = ?";
String[] selectionArgs = new String[]{String.valueOf(id)};
return sqdb.query(TABLE_NAME , null , selection , selectionArgs , null , null , null);
}