Web サービスを使用して Android でアプリを作成しています。私がやろうとしているのは同期機能です。Web サーバーからいくつかのプロパティを取得しています。ブール値が 1 つあります。ブール値が true の場合、ダウンロードしたドキュメントが更新されます。
しかし、最初にドキュメントを削除してから置き換える必要があるか、ドキュメントを直接置き換える必要があるかのどちらかで、ここで立ち往生しています。コードは次のようになります。
SoapObject DocResponse = (SoapObject)envelope.getResponse();
Log.i("Uspdated Documentss", DocResponse.toString());
for(int i=0; i < DocResponse.getPropertyCount(); i++)
{
SoapObject SingleSubFolder = (SoapObject)DocResponse.getProperty(i);
ID = SingleSubFolder.getProperty(0).toString();
fileLongName = SingleSubFolder.getProperty(1).toString();
UserFileName = SingleSubFolder.getProperty(2).toString();
url = SingleSubFolder.getProperty(3).toString();
fileExtension = SingleSubFolder.getProperty(4).toString();
lastModifiedDate = SingleSubFolder.getProperty(5).toString();
SubjectType = SingleSubFolder.getProperty(6).toString();
IsUpdated = SingleSubFolder.hasProperty("IsUpdated");
db = new DMS_Database(context);
if(IsUpdated==true)
{
// How to perform replace function from database here???
// Is there any need of download manager so that again it download new folder into the phone storage or into the database???
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.setTitle(UserFileName);
// in order for this if to run, you must use the android 3.2 to compile your app
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
{
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
}
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS + "/Downloads", UserFileName);
DownloadManager manager = (DownloadManager)Activtyclass.mAct.getSystemService(Context.DOWNLOAD_SERVICE);
manager.enqueue(request);
}
db.close();
}
}
catch(Exception e)
{
e.printStackTrace();
Toast.makeText(context, " Network Exception : " + e
+ "Please check network connectivity.", Toast.LENGTH_LONG).show();
}
データベース:これは私のデータベース メソッドです...正しいですか???
public void update_Doc(String Id, String name, String url)
{
SQLiteDatabase db = this.getWritableDatabase();
ContentValues updatenote = new ContentValues();
updatenote.put(DOCUMENT_ID, Id);
updatenote.put(DOCUMENT_NAME, name);
updatenote.put(DOCUMENT_URL, url);
db.update(DOCUMENT_TABLE, updatenote, DOCUMENT_ID + "=?" , new String[] {String.valueOf(Id)});
}