Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/220.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在数据库中使用数据绘制图形_Android_Database - Fatal编程技术网

Android 在数据库中使用数据绘制图形

Android 在数据库中使用数据绘制图形,android,database,Android,Database,我想在android上绘制一个图形,使用android上已经创建的本地数据库中存储的数据,因此首先我尝试使用以下函数检索插入的数据 public String getname(int i) { Cursor cursor = null; try { SQLiteDatabase db = this.getWritableDatabase(); cursor = db.rawQuery(SQL_CATEGORY_NAME , new String[]

我想在android上绘制一个图形,使用android上已经创建的本地数据库中存储的数据,因此首先我尝试使用以下函数检索插入的数据

public String getname(int i)
{
    Cursor cursor = null;
    try {
        SQLiteDatabase db = this.getWritableDatabase();
        cursor = db.rawQuery(SQL_CATEGORY_NAME , new String[] { Integer.toString(i) } );
        return (cursor.moveToFirst()) ? cursor.getString(0) : null;
    } finally {
        if (cursor != null) cursor.close();
    }
}
然后,我使用以下代码将其值插入到图形中:

public class Graphe extends AppCompatActivity {
Helper h;
Contact c ;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_graphe);
    GraphView graphView=  findViewById(R.id.graphe);
    LineGraphSeries<DataPoint>series = new LineGraphSeries<>();
    for (int x=1 ; x<c.getId(); x++ )
    {
        series.appendData(new DataPoint(Double.parseDouble(h.getname(c.getId())),x),true,c.getId());
    }
graphView.addSeries(series);
}
公共类图表扩展了AppCompative活动{
助手h;
联系c;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_graph);
GraphView GraphView=findViewById(R.id.graph);
LineGraphSeries=新的LineGraphSeries();

对于(int x=1;x函数中的字符串是从此行重新加载的:私有静态最终字符串SQL_CATEGORY_NAME=“SELECT”+“nom”+”from“+”contact“+”,其中“+”ID+“=?”;