| | |
| | | import android.text.TextUtils; |
| | | |
| | | import com.basic.security.utils.Constants; |
| | | import com.basic.security.utils.FrameUtil; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | |
| | | |
| | | public static Map<String, List<String>> tableColumnNames = new HashMap<>(); |
| | | |
| | | public static Map<String, String> cursorToModelAdapter(Cursor cursor, String table) { |
| | | public static Map<String, String> cursorToModelAdapter(Cursor cursor, String table) {// |
| | | Map<String, String> modelAdapter = new HashMap<>(); |
| | | String[] columnNames = cursor.getColumnNames(); |
| | | for (String columnName : columnNames) { |
| | |
| | | return this; |
| | | } |
| | | } |
| | | |
| | | |
| | | public static Map<String, String> findById(String table, String id) { |
| | | Cursor cursor = null; |
| | | try { |
| | | String sql = "select * from "+table+" where id = '" + id + "'"; |
| | | if (Constants.printSql) { |
| | | System.out.println("findById="+sql |
| | | // + " " + FrameUtil.getFrames() |
| | | ); |
| | | } |
| | | cursor = DatabaseManager.getDatabase().rawQuery(sql, null); |
| | | if (cursor.moveToFirst()) { |
| | | return cursorToModelAdapter(cursor, table); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | if (cursor != null) |
| | | cursor.close(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | } |