어쩌면 당신은 이와 같은 클래스로 액세스 할 수 있습니다.
import java.io.BufferedInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;
import android.os.AsyncTask;
import android.util.Log;
public class DownloadWebPageTask extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... urls) {
String response = "";
String DB_NAME = "sqlbeerlist.sqlite";
try {
URL url = new URL(urls[0]);
URLConnection connection = url.openConnection();
connection.connect();
// this will be useful so that you can show a typical 0-100% progress bar
int fileLength = connection.getContentLength();
// download the file
InputStream input = new BufferedInputStream(url.openStream());
OutputStream output = new FileOutputStream("/sdcard/"+DB_NAME);
byte data[] = new byte[1024];
long total = 0;
int count;
while ((count = input.read(data)) != -1) {
total += count;
// publishing the progress....
//publishProgress((int) (total * 100/fileLength));
output.write(data, 0, count);
}
output.flush();
output.close();
input.close();
} catch (IOException e) {
Log.d("ImageManager", "Error: " + e);
}
return response;
}
}
패키지 com.yourpackage 안드로이드 직접 JDBC를 사용하여 데이터베이스 서버에 연결할 수있는 작업 사용
String sUrl = "URL TO YOUR FILE";
DownloadWebPageTask task = new DownloadWebPageTask();
task.execute(new String[] { sUrl });
를 실행합니다. 파이어 버드 데이터베이스를 이런 식으로 커스텀 임베디드 애플리케이션에 사용하고 있습니다. 그러나, 나는 또한 제안하고 webservice를 사용하는 것이 좋습니다 줄. – lopisan