"storing too much data" in IOS5

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • "storing too much data" in IOS5

    Hallo,

    meine App wurde "rejected" mit folgender Meldung:
    2.23 Apps must follow the iOS Data Storage Guidelines or they will be rejected

    We found that your app does not follow the iOS Data Storage Guidelines, which is not in compliance with the App Store Review Guidelines.

    In particular, we found that your app downloads content and is storing too much data in the incorrect location.

    The iOS Data Storage Guidelines specify:

    "1. Only documents and other data that is user-generated, or that cannot otherwise be recreated by your application, should be stored in the /Documents directory and will be automatically backed up by iCloud.

    2. Data that can be downloaded again or regenerated should be stored in the /Library/Caches directory. Examples of files you should put in the Caches directory include database cache files and downloadable content, such as that used by magazine, newspaper, and map applications.

    3. Data that is used only temporarily should be stored in the /tmp directory. Although these files are not backed up to iCloud, remember to delete those files when you are done with them so that they do not continue to consume space on the user’s device.

    4. Use the "do not back up" attribute for specifying files that should remain on device, even in low storage situations. Use this attribute with data that can be recreated but needs to persist even in low storage situations for proper functioning of your app or because customers expect it to be available during offline use. This attribute works on marked files regardless of what directory they are in, including the Documents directory. These files will not be purged and will not be included in the user's iCloud or iTunes backup. Because these files do use on-device storage space, your app is responsible for monitoring and purging these files periodically."

    For example, only content that the user creates using your app, e.g., documents, new files, edits, etc., may be stored in the /Documents directory - and backed up by iCloud.

    Temporary files used by your app should only be stored in the /tmp directory; please remember to delete the files stored in this location when the user exits the app.

    Data that can be recreated but must persist for proper functioning of your app - or because customers expect it to be available for offline use - should be marked with the "do not back up" attribute. For more information, please see Technical Q&A 1719: How do I prevent files from being backed up to iCloud and iTunes?.

    It would be appropriate to revise your app to meet the requirements of the iOS Data Storage Guidelines.


    Ich verwende eine SQLLite 3 Datenbank, die im Users Filesystem gespeichert wird.
    Offenbar wird diese Datenbank dann unter IOS5 in der iCloud gespeichert und muss daher entweder im temp- oder im Cache-Verzeichnis gespeichert werden.

    Hier meine Fragen:
    1. Soll ich die Datenbank im Temp- oder im Cache-Verzeichnis speichern ?
    2. Wie muss ich meinen Code anpassen, damit die SQLLite-Datenbank in diesem Verzeichnis gespeichert wird?
    3. Muss ich die Datenbank mit jedem Start der App wieder aus dem Bundle kopieren, da Cache und Temp-Ordner ggf. gelöscht werden können?

    Hier der Code:

    Quellcode

    1. - (void) copyDatabaseIfNeeded {
    2. // Check if the SQL database has already been saved to the users phone, if not then copy it over"
    3. // Create a FileManager object, we will use this to check the status of the database and to copy it over if required"
    4. NSFileManager *fileManager = [NSFileManager defaultManager];
    5. NSError *error;
    6. NSString *dbPath = [self getDBPath];
    7. NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"NamederSQLDatenbank.sqlite"];
    8. // Check if the database has already been created in the users filesystem
    9. BOOL copyDB = [fileManager fileExistsAtPath:dbPath];
    10. NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    11. int dbVersion = [defaults integerForKey:@"DBVersFoemVoll"];
    12. copyDB &= dbVersion != DB_VERSION;
    13. // If the database already exists then return without doing anything
    14. if(!copyDB) {
    15. // If not then proceed to copy the database from the application to the users filesystem
    16. [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"NamederSQLDatenbank.sqlite"];
    17. // Copy the database from the package to the users filesystem
    18. [fileManager removeItemAtPath:dbPath error:nil];
    19. BOOL success = [fileManager copyItemAtPath:defaultDBPath toPath:dbPath error:&error];
    20. if (!success) NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]);
    21. else {
    22. [defaults setInteger:DB_VERSION forKey:@"DBVersFoemVoll"];
    23. [defaults synchronize];
    24. }
    25. }
    26. }
    27. - (NSString *) getDBPath {
    28. NSArray *paths= NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    29. return [[paths objectAtIndex:0] stringByAppendingPathComponent:@"NamederSQLDatenbank.sqlite"];
    30. }
    Alles anzeigen


    Beste Grüße
    Alexander
  • Ich sag ja ich habe das noch nicht probiert da ich nur veränderbare Datenbanken habe.

    Den Code solltest schon selber ändern, ich gebe gerne Ideen aber die Arbeit sollte der Programmierer schon selber machen

    Gruß

    Claus
    2 Stunden Try & Error erspart 10 Minuten Handbuchlesen.

    Pre-Kaffee-Posts sind mit Vorsicht zu geniessen :)
  • Herr H., ihnen mangelt es anscheinend an Grundlagen, was man auch an dem obigen zusammenkopierten Tutorial-Code sieht, den sie selbst noch nicht einmal verstehen.
    NSCachesDirectory und NSTemporaryDirectory() ist das, was Sie suchen.
    Allerdings, da sich an der DB sowieso nie etwas ändert, ist es besser, wie von Thallius vorgeschlagen, aus dem Bundle zu laden. Sonst kostet es den User doppelt Speicher, wie Apple schon bemängelt hat.
  • Ich denke, ich muss nur
    NSDocumentDirectory
    ersetzen durch

    NSCachesDirectory


    und bei jedem Start der App die SQLLite-DB aus dem Bundle in die Cache-Directory rüberbügeln.


    Quellcode

    1. - (NSString *) getDBPath {
    2. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
    3. NSString *documentsDir = [paths objectAtIndex:0];
    4. NSLog(@"success54");
    5. return [documentsDir stringByAppendingPathComponent:@"FoerdermittelV1.sqlite"];
    6. }
  • robin_ schrieb:

    Hier werden dir nur wenige bis gar keine den Code vorschreiben, wenn du ja indirekt zugibst, alles nur kopiert zu haben

    Ich habe weder direkt noch indirekt gesagt, dass ich alles nur kopiert habe. 90% meiner Apps schreibe ich selbst, aber für einige Teile, die für mich neu sind, muss ich eben Anregungen finden. Das macht jeder Entwickler, Du sicher auch. V

    ielen Dank für Deinen wichtigen Beitrag!
  • Glaub mir ich versuche immer auf die Probleme der Erstellet einzugehen

    Aber wenn ich mir das so angucke, dann finde ich in fast jeden Beitrag anderer User schon einen Hinweis bzw. eine Sache womit du etwas verändern könntest.
    Wenn du dann nicht weiß, was du tun sollst, kannst du ja immer noch fragen, wo du dich da einlesen kannst, (Hilfe zur Selbsthilfe ist hier eher angebracht)

    MFG
    Gruß

    Robin
  • Erich H. schrieb:

    mattik schrieb:

    Es wurde hier doch schon mehrfach erwähnt, dass das Kopieren von Readonly-Dateien aus dem Bundle vollkommen unsinnig ist - warum bestehst Du darauf, das Ding irgendwohin kopieren zu wollen?

    Du hast ja recht - allerdings habe ich noch kein Code-Beispiel gefunden, das mir zeigt, wie das geht.

    Wie müßte ich meinen Code umschreiben?

    Bin für jeden Hinweis dankbar. 8|

    Alles was Du dafür brauchst steht oben schon. Nur dass Du die ganze Kopiererei weglässt und als Datenbankpfad gleich den Pfad im Bundle nimmst.
    Multigrad - 360°-Produktfotografie für den Mac