2017-09-06 1 views
-1

Ich habe 5 Spalte in sq lite Datenbankandroid SQLite für bestimmte Spalte retrive

   id name mark  phone   address 
       1 a  55  888880  fgererlkjioe 
       2 b  65  87689546  hhfgahjfhj 

1.Ich möchte den Namen Spalte vollständig 2. wenn das Auswahl bestimmten Namen Methode das neue Feld Zeichen, Telefon aktualisieren abrufen und adresse,

ich meinen Code versuchen

geben unter
 Creation of database 
    private static final String TABLE_CONTACTS = "contacts"; 
      // Contacts Table Columns names 
      private static final String KEY_ID = "id"; 
      private static final String KEY_STDNAME = "std_name"; 
private static final String KEY_ADDRESS = "address"; 
private static final String KEY_DATE = "dob"; 
private static final String KEY_PH_NO = "phone_number"; 
private static final String KEY_EMAIL = "std_email"; 
private static final String MARK ="std_mark"; 
private static final String AGE ="age"; 

public MyDatabase(Context context) { 
    super(context, DATABASE_NAME, null, DATABASE_VERSION); 
} 

//Create tables 
@Override 
public void onCreate(SQLiteDatabase db) { 
    String CREATE_TABLE_CONTACTS="CREATE TABLE " + TABLE_CONTACTS + "(" 
      + KEY_ID +" INTEGER PRIMARY KEY," 
      + KEY_STDNAME +" TEXT," 
      + KEY_ADDRESS +" TEXT," 
      + MARK +" INTEGER," 
      + AGE +" TEXT," 
      + KEY_DATE +" TEXT," 
      + KEY_EMAIL +" TEXT," 
      + KEY_PH_NO +" INTEGER" + ")"; 
    db.execSQL(CREATE_TABLE_CONTACTS); 
} 

// Abfragemethode ruft die Datenbank

SQLiteDatabase db = this.getWritableDatabase(); 

    String table = TABLE_CONTACTS; 
    String[] columns = {"std_name"}; 
    String selection = null; 
    String[] selectionArgs =null; 
    String groupBy = null; 
    String having = null; 
    String orderBy = null; 
    String limit = null; 

    Cursor cursor = db.query(table, columns, selection, selectionArgs, groupBy, having, orderBy, limit); 
+0

Prüfung Link https://stackoverflow.com/questions/7387455/android-sqlite-how-to-retrieve-specific-data-from-particular -Spalte und das https://StackOverflow.com/Questions/9412040/How-to-get-Column-value-from-sqlite-cursor –

+0

dies auch https://stackoverflow.com/questions/5974799/how-can- ich-reveal-a-particular-column-from-sqlite-in-android und diese https://stackoverflow.com/questions/6653502/android-sqlite-how-to-get-particular-columstrow-value –

+0

Ich versuchte aldredy – Jayapriya

Antwort

0

Verwendung dieses String table = "contacts"; insted String table = TABLE_CONTACTS;

SQLiteDatabase db = this.getWritableDatabase(); 

String table = "contacts"; 
String[] columns = {"std_name"}; 
String selection = null; 
String[] selectionArgs =null; 
String groupBy = null; 
String having = null; 
String orderBy = null; 
String limit = null; 

Cursor cursor = db.query(table, columns, selection, selectionArgs, groupBy, having, orderBy, limit);