| 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | Select ไปใช้ 2 หน้าหรือว่ายังไงครับ ลองอธิบายเพิ่มเติม ภาพประกอบ/ข้อผิดพลาด 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-04-19 09:57:23 | By :
                            mr.win |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | หน้าแรกนะครับ Code (Android-Java)
 
 final Database daba = new Database(this);
try {
					String resultServer = getJSONUrl(url, params1);
					JSONArray data = new JSONArray(resultServer);
					
					mArrList = new ArrayList<HashMap<String, String>>();
					HashMap<String, String> map;
					
					for(int i = 0; i < data.length(); i++){
		                JSONObject c = data.getJSONObject(i);
		    			
		    			String id1 = c.getString("id");
		    			String name1 = c.getString("name");
		    			String address1 = c.getString("address");
		    			String latitude1 = c.getString("latitude");
		    			String longtitude1 = c.getString("longtitude");
		    			
		    			daba.insertdb(id1,name1,address1,latitude1,longtitude1);  /// insert ไป sqlite
		                Log.i("Recieve"+i,id1+" "+name1); 
					}
				} catch (JSONException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
 หน้าที่เกี่ยวกับ Database นะครับ
 Code (Android-Java)
 
 public class Database extends SQLiteOpenHelper {
	
	private static final String DB_NAME = "mydatabase";
	private static final String TABLE_MEMBER = "schedule1";
    private static final int DB_VERSION = 1;
    SQLiteDatabase db;
    
	public Database(Context context) {
		super(context, DB_NAME, null, DB_VERSION);
		// TODO Auto-generated constructor stub
	}
	
	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
	
			db.execSQL("CREATE TABLE " + TABLE_MEMBER + "("
                + "idk INTEGER primary key AUTOINCREMENT,"
                + "id TEXT(100)," 
                + "name TEXT(100),"
                + "address TEXT(100),"
                + "latitude INTEGER,"
                + "longtitude INTEGER);");
			Log.d("CREATE TABLE","Create Table Successfully.");
	}
	public void insertdb(String id1,String name1,String address1,String latitude1,String longtitude1){
		 
		try{
			db = this.getWritableDatabase(); // Write Data
			
			db.execSQL("INSERT or replace INTO "+TABLE_MEMBER+" (idk,id,name,address,latitude,longtitude) " +
		                "VALUES(NULL,'"+id1+"','"+name1+"','"+address1+"','"+latitude1+"','"+longtitude1+"')");
		    db.close();
		 }catch(Exception e){e.printStackTrace();}
	}
	
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		db.execSQL("DROP TABLE "+TABLE_MEMBER);
		// Re Create on method  onCreate
        onCreate(db);
	}
	
	public Cursor selectdata(){
		try{
			db = this.getReadableDatabase(); // Read Data
			String strSQL = "SELECT * FROM " + TABLE_MEMBER;
			Cursor cursor = db.rawQuery(strSQL, null);
			return cursor;
		}catch(Exception e){return null;}
	} 
}
 และหน้าที่ 3 ที่มีปัญหานะครับ
 Code (Android-Java)
 
 public class Googlemap extends FragmentActivity {
	private GoogleMap myMap;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_googlemap);
		
		 SupportMapFragment mySupportMapFragment = 
                (SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map_canvas);
         myMap = mySupportMapFragment.getMap();
         
 		 myMap.setMyLocationEnabled(true);
 		Database daba = new Database(this);
		Cursor locationCursor = daba.selectdata();
		int i=0;
 		do {
 	        String id = locationCursor.getString(locationCursor
 	                .getColumnIndex("id"));
 	        String name = locationCursor.getString(locationCursor
 	                .getColumnIndex("name"));
 	        Double latitude = (Double) locationCursor.getDouble(locationCursor
 	                .getColumnIndex("latitude"));
 	        Double longitude = (Double) locationCursor.getDouble(locationCursor
 	                .getColumnIndex("longtitude"));
 	       Log.i("Recieve"+i,idowner+" "+latitude);
 	       i++;
// 	        try{
// 	        	myMap.addMarker(new MarkerOptions()
// 	        	.position(new LatLng(latitude, longitude))
//                .title(id)
//                .snippet(name)
//                .icon(BitmapDescriptorFactory.defaultMarker()));
// 	        }catch(Exception e){e.printStackTrace();}
 		}while(locationCursor.moveToNext());
 	}
}
 Code
 
 04-19 18:10:05.734: E/AndroidRuntime(4775): FATAL EXCEPTION: main
04-19 18:10:05.734: E/AndroidRuntime(4775): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.police/com.example.police.Googlemap}; have you declared this activity in your AndroidManifest.xml?
04-19 18:10:05.734: E/AndroidRuntime(4775): 	at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1508)
04-19 18:10:05.734: E/AndroidRuntime(4775): 	at android.app.Instrumentation.execStartActivity(Instrumentation.java:1384)
04-19 18:10:05.734: E/AndroidRuntime(4775): 	at android.app.Activity.startActivityForResult(Activity.java:3190)
04-19 18:10:05.734: E/AndroidRuntime(4775): 	at android.app.Activity.startActivity(Activity.java:3297)
04-19 18:10:05.734: E/AndroidRuntime(4775): 	at com.example.police.DetailActivity$1$1.onClick(DetailActivity.java:123)
04-19 18:10:05.734: E/AndroidRuntime(4775): 	at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:166)
04-19 18:10:05.734: E/AndroidRuntime(4775): 	at android.os.Handler.dispatchMessage(Handler.java:99)
04-19 18:10:05.734: E/AndroidRuntime(4775): 	at android.os.Looper.loop(Looper.java:137)
04-19 18:10:05.734: E/AndroidRuntime(4775): 	at android.app.ActivityThread.main(ActivityThread.java:4424)
04-19 18:10:05.734: E/AndroidRuntime(4775): 	at java.lang.reflect.Method.invokeNative(Native Method)
04-19 18:10:05.734: E/AndroidRuntime(4775): 	at java.lang.reflect.Method.invoke(Method.java:511)
04-19 18:10:05.734: E/AndroidRuntime(4775): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-19 18:10:05.734: E/AndroidRuntime(4775): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-19 18:10:05.734: E/AndroidRuntime(4775): 	at dalvik.system.NativeStart.main(Native Method)
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-04-19 18:26:22 | By :
                            Film |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
 
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | สมัครสมาชิก จะแก้ไขได้ครับ  
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-04-20 19:15:10 | By :
                            mr.win |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | เคครับ นั่งทำจนได้และครับ คือผม สร้าง class selectAll มาเพิ่มครับก็จะได้แบบนี้ Code (Android-Java)
 
 import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
public class Dbselect {
	private SQLiteDatabase db;
	
	public Dbselect(Context context){
		db = this.getReadableDatabase();
	}
	
	public Cursor selectdata(){
		try{
			String strSQL = "SELECT * FROM " + TABLE_MEMBER;
			Cursor cursor = db.rawQuery(strSQL, null);
			return cursor;
		}catch(Exception e){return null;}
	} 
}
 แล้วจึงไปเรียกใช้ใน Googlemap ก็จะได้แบบนี้ และผมก็ลืมใส่ locationCursor.moveToFirst(); มันเลย Error ครับ
 
 Code (Android-Java)
 
 import android.content.Context;
import android.database.Cursor;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
public class Googlemap extends FragmentActivity {
	private GoogleMap map;
	private Dbselect db;
	private Context context;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_googlemap);
		
		SupportMapFragment mySupportMapFragment = 
                (SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map_canvas);
         map = mySupportMapFragment.getMap();
         
         map.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(13,100),8));     
         
         context = this;
         db = new Dbselect(context);
         
         Cursor locationCursor = db.selectdata();
          int i=0;
    
        	locationCursor.moveToFirst();
        	do {
        		String id = locationCursor.getString(locationCursor
  	                .getColumnIndex("id"));
        		String name = locationCursor.getString(locationCursor
  	                .getColumnIndex("name"));
        		Double latitude = (Double) locationCursor.getDouble(locationCursor
  	                .getColumnIndex("latitude"));
        		Double longitude = (Double) locationCursor.getDouble(locationCursor
  	                .getColumnIndex("longtitude"));
        		
//        		map.addMarker(new MarkerOptions()
//    		 		.position(new LatLng(latitude, longitude))
//    		 		.icon( BitmapDescriptorFactory.defaultMarker())
//    		 		.title(idowner)
//    		 		.snippet(name));
        		
        		Log.i("test"+i,id+" "+latitude);
  	        		i++;
        	}while(locationCursor.moveToNext());
	}
}
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-04-20 20:05:16 | By :
                            Film |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              |  ยินดีด้วยครับ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-04-20 20:53:33 | By :
                            mr.win |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  |