Aktywne Wpisy
MZ23 +154
No to marzenie spełnione. Od kilku lat myślałem o nowym samochodzie z salonu. Na początku była na tapecie Dacia, ale patrząc na to, że Sandero Stepway miałbym kilkanaście tysięcy mniej niż tego rodzynka zdecydowałem się dopłacić. Pierwsze auto z salonu, przesiadka z Octavii 2 z 2008 roku.
#chwalesie #samochody #motoryzacja #skoda
#chwalesie #samochody #motoryzacja #skoda
m_k_92 +1
Aktywne Znaleziska
Zawiera treści 18+
Ta treść została oznaczona jako materiał kontrowersyjny lub dla dorosłych.
PlaceDatabaseHelper(Context context) {
super(context, "database.db", null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + NAME_PLACE + "(_id INTEGER PRIMARY KEY AUTOINCREMENT," +
"NAME TEXT,"
+ "CITY TEXT,"
+ "DESCRIPTION TEXT );");
insertPlace(db, "Cmentarz", "Gliwice", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
insertPlace(db, "Szpital", "Katowice", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + NAME_PLACE);
onCreate(db);
}
private static void insertPlace(SQLiteDatabase db, String name, String city,
String description) {
ContentValues placeValues = new ContentValues();
placeValues.put("NAME", name);
placeValues.put("CITY", city);
placeValues.put("DESCRIPTION", description);
db.insert("PLACE", null, placeValues);
}
a tutaj prubuje wywolac i przypisać wartości
try {
SQLiteOpenHelper placeDatabaseHelper = new PlaceDatabaseHelper(this);
SQLiteDatabase db = placeDatabaseHelper.getReadableDatabase();
Cursor cursor = db.query("PLACE",
new String[]{"NAME"}, "NAME= ?",
new String[]{"Cmentarz"},
null, null, null);
if (cursor.moveToFirst()) {
// Pobieramy szczegółowe informacje z kursora
String nameText = cursor.getString(1);
String cityText = cursor.getString(2);
String descriptionText = cursor.getString(3);
TextView name = (TextView)findViewById(R.id.textname);
name.setText(nameText);
// Wyświetlamy opis
TextView city = (TextView)findViewById(R.id.textcity);
city.setText(cityText);
// Wyświetlamy
TextView description = (TextView)findViewById(R.id.textdesc);
description.setText(descriptionText);
}
cursor.close();
db.close();
}catch (SQLiteException e)
{
Toast toast = Toast.makeText(this,"Error ptaki latają kluczem", Toast.LENGTH_SHORT);
toast.show();
}