In [emulator][DDMS]
When I put database manualy in data/data/mypackage/databases/ it run smooth.
[Android device]
When I export to apk file and install to android device.
The apps will force close.
when I check in folder path in android devices data/data/myPackage/databases/ there are empty databases in it I dont know where it come from. When I delete that empty database and replace with my existing database. The apps run smooth as feather.
The question is, How to replace database[have data] in asset folder and replace the empty database create itself with database[have data] in asset folder.
Below my coding, If I have mistake please tell me
Thanks who reply me, regards Hafizul Reza
public class MainActivity extends Activity {
ArrayList<OverlayItem> anotherOverlayItemArray;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MapView mapView = new MapView(this, 256);
setContentView(R.layout.activity_main);
mapView.setClickable(true);
mapView.setMultiTouchControls(true);
mapView.setBuiltInZoomControls(true);
setContentView(mapView);
mapView.getController().setZoom(4);
mapView.getController().setCenter(new GeoPoint(4.415895,101.383082));
mapView.setUseDataConnection(false);
mapView.setTileSource(TileSourceFactory.MAPQUESTOSM);
SQLiteDatabase myDB = null;
String TableName = "Landslide";
myDB = this.openOrCreateDatabase("Landslide.sqlite", MODE_PRIVATE, null);
Cursor c = myDB.rawQuery("SELECT * FROM " + TableName, null);
if (c != null) {
if (c.moveToFirst()) {
do {
Double lat = c.getDouble(c.getColumnIndex("Latitude"));
Double lng = c.getDouble(c.getColumnIndex("Longitude"));
anotherOverlayItemArray = new ArrayList<OverlayItem>();
anotherOverlayItemArray.add(new OverlayItem(
"Ringlet", "Cameron Highland", new GeoPoint(lat, lng)));
ItemizedIconOverlay<OverlayItem> anotherItemizedIconOverlay
= new ItemizedIconOverlay<OverlayItem>(this, anotherOverlayItemArray, null);
mapView.getOverlays().add(anotherItemizedIconOverlay);
} while (c.moveToNext());
}
}