Hi I have two array values
loncountries[index] = [80.2116001, 80.173399]
latcountries[index] = [13.042699, 13.0409047]
Now I want them in a new Array like
loncountries[index] = [13.042699,80.2116001]
latcountries[index] = [13.0409047,80.173399]
Just the first columns as a new Array. Also I am fetcihg it from Sqlite Database and attaching the code below. Is it possible to do it during fetching from db.
String[] latcountries;
String[] loncountries;
if (cJoin != null) {
int countJoin = cJoin.getCount();
if (countJoin > 0) {
latcountries = new String[countJoin];
loncountries = new String[countJoin];
int index = 0;
cJoin.moveToFirst();
while (!cJoin.isAfterLast()) {
loncountries[index] = cJoin.getString(0);
latcountries[index] = cJoin.getString(1);
index++;
cJoin.moveToNext();
}
}
}
one approach could be to declare a bean-like class,
public class Position {
public String mLat;
public String mLon;
}
and then declare an array of position:
Position[] latLon = new Position[countJoin];
at every iteration then
while (!cJoin.isAfterLast()) {
Position p = new Position();
p.mLat = cJoin.getString(1);
p.mLon = cJoin.getString(0);
latLon[index++] = p;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.