List of usage examples for android.database Cursor moveToFirst
boolean moveToFirst();
From source file:com.github.gw2app.events.Gw2ApiEvents.java
private HashMap<Integer, String> _getMapNamesFromDB() { Log.d("Gw2", "Fetching map names from DB."); SQLiteDatabase db = this.dbhelper.getReadableDatabase(); Cursor cursor = db.query(Gw2DB.MAP_NAMES_TABLE, null, null, null, null, null, null); cursor.moveToFirst(); HashMap<Integer, String> mapNames = new HashMap<Integer, String>(); while (!cursor.isLast()) { Integer id = cursor.getInt(0); String name = cursor.getString(1); mapNames.put(id, name);/*from ww w. j a v a 2s . c om*/ cursor.moveToNext(); } cursor.close(); return mapNames; }
From source file:be.vbsteven.bmtodesk.SendAllCurrentBookmarksActivity.java
protected ArrayList<Bookmark> getAllBookmarks() { ArrayList<Bookmark> result = new ArrayList<SendAllCurrentBookmarksActivity.Bookmark>(); String[] projection = new String[] { BookmarkColumns.TITLE, BookmarkColumns.URL }; Cursor c = managedQuery(Browser.BOOKMARKS_URI, projection, "bookmark = ?", new String[] { "1" }, null); if (c.moveToFirst()) { int title = c.getColumnIndex(BookmarkColumns.TITLE); int url = c.getColumnIndex(BookmarkColumns.URL); while (!c.isAfterLast()) { Bookmark b = new Bookmark(); b.title = c.getString(title); b.url = c.getString(url);//from ww w. j av a 2 s.c om result.add(b); c.moveToNext(); } } return result; }
From source file:com.github.gw2app.events.Gw2ApiEvents.java
private HashMap<Integer, String> _getWorldNamesFromDB() { Log.d("Gw2", "Fetching world names from DB."); SQLiteDatabase db = this.dbhelper.getReadableDatabase(); Cursor cursor = db.query(Gw2DB.WORLD_NAMES_TABLE, null, null, null, null, null, null); cursor.moveToFirst(); HashMap<Integer, String> worldNames = new HashMap<Integer, String>(); while (!cursor.isLast()) { Integer id = cursor.getInt(0); String name = cursor.getString(1); worldNames.put(id, name);//from w ww . j ava 2 s. c o m cursor.moveToNext(); } cursor.close(); return worldNames; }
From source file:de.tudarmstadt.dvs.myhealthassistant.myhealthhub.services.transformationmanager.database.LocalTransformationDBMS.java
public ArrayList<String> getAllAvalDate() { ArrayList<String> list = new ArrayList<String>(); String q = "SELECT * FROM " + LocalTransformationDB.TABLE_DATE_TO_TRAFFIC + " ORDER BY " + LocalTransformationDB.COLUMN_DATE_ID + ";"; Cursor cursor = database.rawQuery(q, null); if (cursor.moveToFirst()) { do {/*from w w w . j av a 2s . c om*/ String date = cursor.getString(cursor.getColumnIndex(LocalTransformationDB.COLUMN_DATE_TEXT)); if (!list.contains(date)) list.add(date); } while (cursor.moveToNext()); } cursor.close(); Collections.sort(list, new Comparator<String>() { @Override public int compare(String arg0, String arg1) { SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy"); int compareResult = 0; try { Date arg0Date = format.parse(arg0); Date arg1Date = format.parse(arg1); compareResult = arg0Date.compareTo(arg1Date); } catch (ParseException e) { e.printStackTrace(); compareResult = arg0.compareTo(arg1); } return compareResult; } }); for (String s : list) { Log.e(TAG, "AvalDate:" + s); } return list; }
From source file:heartware.com.heartware_master.DBAdapter.java
public HashMap<String, String> getProfilePassword(String id) { HashMap<String, String> profileMap = new HashMap<String, String>(); SQLiteDatabase database = this.getReadableDatabase(); String selectQuery = "SELECT " + PASSWORD + " FROM " + PROFILES_TABLE + " WHERE " + PROFILE_ID + "='" + id + "'"; Cursor cursor = database.rawQuery(selectQuery, null); if (cursor.moveToFirst()) { do {/*from www . j a va2 s. c o m*/ profileMap.put(PASSWORD, cursor.getString(0)); } while (cursor.moveToNext()); } return profileMap; }
From source file:com.pureexe.calinoius.environment.camera.fragment.MainFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); dataManager = new DataManager(getActivity()); try {// w w w.jav a 2s . c om // Use Try catch Exception to avoid force close with CM's Privacy Guard Cursor c = getActivity().getApplication().getContentResolver() .query(ContactsContract.Profile.CONTENT_URI, null, null, null, null); c.moveToFirst(); dataManager.setString("Researcher", c.getString(c.getColumnIndex("display_name"))); } catch (Exception e) { dataManager.setString("Researcher", "Unknown"); } GridView gridview = (GridView) rootView.findViewById(R.id.gridView1); gridview.setAdapter(new HomePageAdapter(getActivity())); gridview.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { if (position == 0) { Intent beepActivity = new Intent(getActivity(), FragmentDisplayActivity.class); beepActivity.setAction(Intent.ACTION_SEND); beepActivity.putExtra(Intent.EXTRA_TEXT, "UserFragment"); beepActivity.setType("beepActivity"); startActivity(beepActivity); } if (position == 1) { Intent intent = new Intent(getActivity(), EnvironmentCameraActivity.class); startActivity(intent); } if (position == 2) { Intent beepActivity = new Intent(getActivity(), FragmentDisplayActivity.class); beepActivity.setAction(Intent.ACTION_SEND); beepActivity.putExtra(Intent.EXTRA_TEXT, "EXIFreadFragment"); beepActivity.setType("beepActivity"); startActivity(beepActivity); } if (position == 3) { Intent beepActivity = new Intent(getActivity(), FragmentDisplayActivity.class); beepActivity.setAction(Intent.ACTION_SEND); beepActivity.putExtra(Intent.EXTRA_TEXT, "SettingPreferenceFragment"); beepActivity.setType("beepActivity"); startActivity(beepActivity); } if (position == 4) { Intent beepActivity = new Intent(getActivity(), FragmentDisplayActivity.class); beepActivity.setAction(Intent.ACTION_SEND); beepActivity.putExtra(Intent.EXTRA_TEXT, "HelpFragment"); beepActivity.setType("beepActivity"); startActivity(beepActivity); } if (position == 5) { Intent beepActivity = new Intent(getActivity(), FragmentDisplayActivity.class); beepActivity.setAction(Intent.ACTION_SEND); beepActivity.putExtra(Intent.EXTRA_TEXT, "AboutFragment"); beepActivity.setType("beepActivity"); startActivity(beepActivity); } } }); return rootView; }
From source file:heartware.com.heartware_master.DBAdapter.java
public HashMap<String, String> getProfileById(String id) { HashMap<String, String> profileMap = new HashMap<String, String>(); SQLiteDatabase database = this.getReadableDatabase(); String selectQuery = "SELECT * FROM " + PROFILES_TABLE + " WHERE " + PROFILE_ID + "='" + id + "'"; Cursor cursor = database.rawQuery(selectQuery, null); if (cursor.moveToFirst()) { do {/*from w w w.ja va2 s .co m*/ profileMap.put(PROFILE_ID, cursor.getString(0)); profileMap.put(USERNAME, cursor.getString(1)); profileMap.put(PASSWORD, cursor.getString(2)); profileMap.put(DIFFICULTY, cursor.getString(3)); profileMap.put(DISABILITY, cursor.getString(4)); } while (cursor.moveToNext()); } return profileMap; }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.AppReferenceObj.java
private SignedObj getAppStateForChildFeed(Context context, Obj appReferenceObj) { JSONObject appReference = appReferenceObj.getJson(); if (DBG)/*from ww w.j av a2 s .c o m*/ Log.w(TAG, "returning app state for " + appReference.toString()); if (appReference.has(DbObject.CHILD_FEED_NAME)) { String feedName = appReference.optString(DbObject.CHILD_FEED_NAME); Uri feedUri = Feed.uriForName(feedName); String selection = "type in ('" + AppStateObj.TYPE + "')"; String[] projection = null; String order = "_id desc LIMIT 1"; Cursor c = context.getContentResolver().query(feedUri, projection, selection, null, order); if (c.moveToFirst()) { return App.instance().getMusubi().objForCursor(c); } } else if (appReference.has("state")) { return (SignedObj) appReferenceObj; } return null; }
From source file:io.vit.vitio.Managers.ConnectDatabase.java
public List<Course> getCoursesList() { List<Course> courses = new ArrayList<>(); String selectQuery = "SELECT * FROM " + TABLE_COURSES; try {// w w w .j a v a2 s . c o m SQLiteDatabase db = this.getWritableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); if (cursor.moveToFirst()) { do { Course course = new Course(); course.setCLASS_NUMBER(cursor.getString(0)); course.setCOURSE_TITLE(cursor.getString(1)); course.setCOURSE_SLOT(cursor.getString(2)); course.setCOURSE_TYPE(cursor.getString(3)); course.setCOURSE_TYPE_SHORT(cursor.getString(4)); course.setCOURSE_LTPC(cursor.getString(5)); course.setCOURSE_CODE(cursor.getString(6)); course.setCOURSE_MODE(cursor.getString(7)); course.setCOURSE_OPTION(cursor.getString(8)); course.setCOURSE_VENUE(cursor.getString(9)); course.setCOURSE_FACULTY(cursor.getString(10)); course.setCOURSE_REGISTRATIONSTATUS(cursor.getString(11)); course.setCOURSE_BILL_DATE(cursor.getString(12)); course.setCOURSE_BILL_NUMBER(cursor.getString(13)); course.setCOURSE_PROJECT_TITLE(cursor.getString(14)); course.setJson(new JSONObject(cursor.getString(15))); course.setCOURSE_ATTENDANCE(ParseCourses.getAttendance(new JSONObject(cursor.getString(16)))); course.setCOURSE_TIMING(ParseCourses.getTimings(new JSONArray(cursor.getString(17)))); course.setCOURSE_MARKS(ParseCourses.getCouseMarks(new JSONObject(cursor.getString(18)))); courses.add(course); } while (cursor.moveToNext()); } cursor.close(); db.close(); } catch (Exception e) { e.printStackTrace(); SQLiteDatabase _db = this.getWritableDatabase(); if (_db != null && _db.isOpen()) { _db.close(); } } return courses; }