I m using static database to fetch data. I m fetching longitude and latitude of static location from database, storing it in string and using. What if i want to extract all longitude and latitude and store it in an array...i mean array of size [137][15] storing latitude and longitude in a single 2d array.....or 2 separate 1 d array. One for latitude ..another for latitude...
DataBaseHelper2 mDbHelper = new DataBaseHelper2(this);
try {
mDbHelper.createDataBase();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
mDbHelper.openDataBase();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Spinner s1=(Spinner) findViewById(R.id.spinner1);
int index1=s1.getSelectedItemPosition();
String Text1 = s1.getSelectedItem().toString();
String Text3="";
String Text4="";
if(index1==0)
{
Toast.makeText(getApplicationContext(),"Please Enter station", Toast.LENGTH_SHORT).show();
}
else{
Cursor c=mDbHelper.fetchQuery(Text1);
int latitude = c.getColumnIndex("lat");
int longitude = c.getColumnIndex("lng");
for(c.moveToFirst();!c.isAfterLast();c.moveToNext()){
Text3=Text3 + c.getString(latitude)+"\n";
Text4=Text4 + c.getString(longitude)+"\n";
}
Double p,p1;
p=Double.valueOf(Text3).doubleValue();
p1=Double.valueOf(Text4).doubleValue();
fetchquery is a method to extract longitude and latitude where name of station matches with text of spinner1.