Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

113
Views
GraphView with data from sqlite not displaying

I am having trouble displaying my data from my sqlite database in a line graph using Graph view.

My database has two columns, ID, Points

So my database should look as follows:

ID|Points

1 | 35

2 | 55

3 | 62

However i'm not sure as to how I could implement this in GraphView.

My database:

 public static final String DATABASE_NAME = "mydatabase.db";
public static final String TABLE_NAME = "my_table";
public static final String COL_1 = "ID";
public static final String COL_2 = "POINTS"; 

x axis = ID y axis = POINTS

Any help on how to implement this would be appreciated.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

First get data from database

SQLiteDatabase db = this.getWritableDatabase();
Cursor  myCursor=db.rawQuery("select * from "+TABLE_NAME,null);

create an arraylist and add data in it.

if(myCursor.getCount()==0){
// contains nothing so show some message to user
return;
}
else {
ArrayList<Integer> mylist = new ArrayList<Integer>;
// 
while(myCursor.moveToNext()){
// dont need first column if we use loop for arraylist
//mylist.add(myCursor.getInt(cursor.getColumnIndex("COL_1")));
mylist.add(myCursor.getInt(cursor.getColumnIndex("COL_2")));
}

now create a graph object and add your data (it will show just 3 datasets but you can create an loop and show all data

raphView graph = (GraphView) findViewById(R.id.graph);
LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>(new DataPoint[] {

//just for 3 datasets
              new DataPoint(0,mylist.get(0)),
               new DataPoint(1,mylist.get(1)),
               new DataPoint(2,mylist.get(2))
        });
graph.addSeries(series);

hope answerd the question ( if its useful than vote up )

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!