I am working on a project that does something similar. I request database updates and depending on the amount of updates needed, it either sends a completely new database or a series of SQL statements. I would highly recommend storing databases on an SD card if available, especially if the size of the databases you download is variable and only a few kilobytes in size.
, ( , XML SOAP, .)
fileStream = new FileOutputStream(new File(I-build-my-filename-stuff-above-here));
while((i = httpResponse.read(fileData)) > -1) {
fileStream.write(fileData, 0, i);
position += i;
if (item.getUpdateType() == UpdateItem.FULL_FILE) {
progress = position / item.getSize();
} else {
progress = position / (item.getSize() * 2);
}
item.setProgress(progress);
}
fileStream.close();
httpResponse.close();
. iPhone, , Android, SQLiteDatabase.NO_LOCALIZED_COLLATORS. , Database SQLiteOpenHelper:
public Database(Context context, String fileName, String title) {
super(context, fileName, null, 1);
this.context = context;
this.title = title;
this.fileName = fileName;
if (fileName != null && fileName.contains("/sdcard")) {
db = SQLiteDatabase.openDatabase(fileName, null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.CREATE_IF_NECESSARY);
} else {
db = getWritableDatabase();
}
}