There are several columns in a sqlite table. I want to retrieve a particular data using row id. For example : I want the data of the column "name" which have row id "1". How can I do this in android?
            Asked
            
        
        
            Active
            
        
            Viewed 650 times
        
    -3
            
            
        - 
                    Possible duplicate of [What are the best practices for SQLite on Android?](http://stackoverflow.com/questions/2493331/what-are-the-best-practices-for-sqlite-on-android) – Vyacheslav Dec 03 '16 at 14:36
1 Answers
0
            
            
        An example of my code:
private static String t(String i, String table) {
        SQLiteDatabase db = ODB.getInstance().openDatabase();
        String lng = hl;
        String Sid = "Sid___";
        String sql = "SELECT " + lng + "  FROM " + table  + " WHERE " + Sid + " = '" +  i + "'";
        Cursor cur = db.rawQuery(sql, null);
        String out = "";
         if (cur.moveToFirst()) {
             do {
                 out =(cur.getString(0);
                } while (cur.moveToNext());
              }else{
                  throw new NullPointerException();
              }
         cur.close();
         ODB.getInstance().closeDatabase();
         return out;
    }
 
    
    
        Vyacheslav
        
- 26,359
- 19
- 112
- 194
 
    