Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

get data from database sqlite android

//Put this in your DAO or actyvity

public ArrayList<yourclass> getfromdatabase() {
String strSql = "select * from yourtable";
getdatabase = new ArrayList<yourclass>();
SQLiteDatabase db = dbHelper.getReadableDatabase();
Cursor c = db.rawQuery(strSql, null);
if (c.moveToFirst()) {
do {
      yourclass = new yourclass();
      yourclass.setId(c.getInt(c.getColumnIndex("yourcolumnname")));
      yourclass.setTitulo(c.getString(c.getColumnIndex("yourcolumnname")));
      yourclass.setTexto(c.getString(c.getColumnIndex("yourcolumnname")));
      yourclass.setTipo(c.getString(c.getColumnIndex("yourcolumnname")));
      getdatabase.add(yourclass);
   } while (c.moveToNext());
}
     return getdatabase;
}
Comment

PREVIOUS NEXT
Code Example
Java :: How to efficiently find the start node of a loop within a singly linked list, in Java? 
Java :: reverse negative number 
Java :: linkedlist java 
Java :: how to replace an element in array in java 
Java :: settext java 
Java :: sort 2d array based on one column java 
Java :: rock paper scissors java 
Java :: android pass object to activity 
Java :: how to create an entry in java 
Java :: why enable multidex android 
Java :: convert object array to int array java 
Java :: write message in file java 
Java :: priority queue java comparator 
Java :: list constructor java 
Java :: draw circle with fill java 
Java :: FlutterSound.java uses or overrides a deprecated API. 
Java :: traversing treemap in java 
Java :: get role assigned to a user inside spring controller 
Java :: java.lang.NoClassDefFoundError: 
Java :: Android Number Picker format JAVA 
Java :: java return new instance of generic type 
Java :: slice() in typesript 
Java :: locked screen android studio 
Java :: how to return the first character in an array from a method java 
Java :: how to get start char in string in java 
Java :: android activity keyboard hide 
Java :: export java path in ubuntu 
Java :: maximum number from random number in java 
Java :: java string stringbuilder array list tostring 
Java :: how use a if in java 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =