Updating Sqlite Database Without Xml

Updating sqlite database without XML

I ultimately ended up using AFNetworking to solve my problem, as suggested by @silver_belt. I was able to do it without subclassing AFHTTPClient though (see my answer here, which I posted as a follow up to this question).

In the end, I just had to #include "AFHTTPRequestOperation.h" in my view controller's .h file, then in the .m I used

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"ftp://myUsername:myPassword@www.mysite.net/myfile.sqlite"]];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
NSURL *path = [[[app applicationDocumentsDirectory] URLByAppendingPathComponent:@"myfile"] URLByAppendingPathExtension:@"sqlite"];
operation.outputStream = [NSOutputStream outputStreamWithURL:path append:NO];

[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject)
{
NSLog(@"Successfully downloaded file to path: %@",path);
}
failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
NSLog(@"Error in AFHTTPRequestOperation in clickedButtonAtIndex on FlightInfoController.m");
NSLog(@"%@",error.description);
}];

[operation start];

when I actually wanted to start my download. Hope this will make it easier for anyone looking to do this in the future!

Android - I can't update data from SQLite Database

Ar you trying to update a list item when clicked on the button acceitarBotao?
If so, I would suggest calling a function that fetches data from sqlite for that sprcific ID (the position of the clicked listitem is the id) and updates that specific list item, and than calls the method notifyDatasetChanged, to notify the adapter that sprcific list item has changed, so it would uldate the listview properly.

Android | SQLLite : Pre-created database updating without using SQLiteOpenHelper

two nights ago I wrote something like that.

  • pack your database structure as an array in a webservice method by reading field names and field types. the structure of array is arbitrary.
  • call web service method and you must receive a string that represent a JSONArray object, if you sent it as json with json_encode() method in php.
  • read structure and make CREATE DB query string with for loops.
  • execute query, so you must have database.
  • also you can send alot of information with arrays.
  • introducing each part is hard, so for each part google it.
  • don't forget to convert field types to match SQLite types such as VARCHAR=>TEXT, smallint=>INTEGER , ...

Xml or Sqlite, When to drop Xml for a Database?

I basically agree with Mitchel, that this can be highly specific depending on what are you going to do with XML and SQLite. For your case (cache), it seems to me that using SQLite (or other embedded databases) makes more sense.

First I don't really think that SQLite will need more overhead than XML. And I mean both development time overhead and runtime overhead. Only problem is that you have a dependence on SQLite library. But since you would need some library for XML anyway it doesn't matter (I assume project is in C/C++).

Advantages of SQLite over XML:

  • everything in one file,
  • performance loss is lower than XML as cache gets bigger,
  • you can keep feed metadata separate from cache itself (other table), but accessible in the same way,
  • SQL is probably easier to work with than XPath for most people.

Disadvantages of SQLite:

  • can be problematic with multiple processes accessing same database (probably not your case),
  • you should know at least basic SQL. Unless there will be hundreds of thousands of items in cache, I don't think you will need to optimize it much,
  • maybe in some way it can be more dangerous from security standpoint (SQL injection). On the other hand, you are not coding web app, so this should not happen.

Other things are on par for both solutions probably.

To sum it up, answers to your questions respectively:

  1. You will not know, unless you test your specific application with both back ends. Otherwise it's always just a guess. Basic support for both caches should not be a problem to code. Then benchmark and compare.

  2. Because of the way XML files are organized, SQLite searches should always be faster (barring some corner cases where it doesn't matter anyway because it's blazingly fast). Speeding up searches in XML would require index database anyway, in your case that would mean having cache for cache, not a particularly good idea. But with SQLite you can have indexing as part of database.

After updating my SQLite database columns via SQLite Manager, why are the changes not reflected in my Android App?

Looks like you're not setting the rating in your getAllBooks() method in your SQLiteHelper class.

Update and Insert Bulk XML Data into my SQLite Database

I found a link that answers my question and provides a working example of taking an XML document and inserting it into a SQLite database: http://blog.sallarp.com/iphone-core-data-uitableview-drill-down/

Elaborate a mechanism to save objects in SQLite database without write any SQL commands

Other than Core Data, I don't know any solutions that completely free you from writing queries. There are quite a few ORMs out there that can help alleviate the pain, such as Mojo Database. A quick search on GitHub found 16 other ORM projects.

Update Sqlite Database Via Cloud Server

I had a problem like that, but i resolved it differently.

It may not be the best way to do things, but it certainly helped me...

Try using dropbox to store your modified database and when the application has internet connection and when the user wants the update, just download that database and replace with the existing one.

Worked for me.



Related Topics



Leave a reply



Submit