Presentation is loading. Please wait.

Presentation is loading. Please wait.

Android Storage MAY 2013 Hu.Cai. NAME OF PRESENTATION [CHANGE IN SLIDE MASTER] MONTH, YEAR [CHANGE IN SLIDE MASTER] Outline 1.Storage In General 2.SharedPreferences.

Similar presentations


Presentation on theme: "Android Storage MAY 2013 Hu.Cai. NAME OF PRESENTATION [CHANGE IN SLIDE MASTER] MONTH, YEAR [CHANGE IN SLIDE MASTER] Outline 1.Storage In General 2.SharedPreferences."— Presentation transcript:

1 Android Storage MAY 2013 Hu.Cai

2 NAME OF PRESENTATION [CHANGE IN SLIDE MASTER] MONTH, YEAR [CHANGE IN SLIDE MASTER] Outline 1.Storage In General 2.SharedPreferences 3.File 4.Database 5.External Storage(SDCard and Network) 2

3 NAME OF PRESENTATION [CHANGE IN SLIDE MASTER] MONTH, YEAR [CHANGE IN SLIDE MASTER] 1. Storage In General 3 APP StorageInternalSharedPreferencesFileDatabaseExternalSDCardNetwork

4 NAME OF PRESENTATION [CHANGE IN SLIDE MASTER] MONTH, YEAR [CHANGE IN SLIDE MASTER] 2. SharedPreferences 4  Store private primitive data in key-value pairs, data type include: boolean,int,float,long,string  This data will persist across user sessions, even if your application is killed

5 NAME OF PRESENTATION [CHANGE IN SLIDE MASTER] MONTH, YEAR [CHANGE IN SLIDE MASTER] SharedPreferences Sample 5 Activity- A, write data Activity- B, read data

6 NAME OF PRESENTATION [CHANGE IN SLIDE MASTER] MONTH, YEAR [CHANGE IN SLIDE MASTER] SharedPreferences Sample 6 /data /data/package_name/shared_prefs/config.xml conclusion : light-weight option

7 NAME OF PRESENTATION [CHANGE IN SLIDE MASTER] MONTH, YEAR [CHANGE IN SLIDE MASTER] 3. File 7  Store private data on the device memory.  When the user uninstalls your app, these files are removed.

8 NAME OF PRESENTATION [CHANGE IN SLIDE MASTER] MONTH, YEAR [CHANGE IN SLIDE MASTER] Internal Storage Sample - File 8 Activity- A, write data Activity- B, read data

9 NAME OF PRESENTATION [CHANGE IN SLIDE MASTER] MONTH, YEAR [CHANGE IN SLIDE MASTER] Internal Storage Sample - File 9 /data /data/package_name/files/test.txt conclusion : middle-weight option, depends on the space of your mobile internal storage.

10 NAME OF PRESENTATION [CHANGE IN SLIDE MASTER] MONTH, YEAR [CHANGE IN SLIDE MASTER] 4. Database 10  Store structured data in a private database.  Any databases you create will be accessible by name to any class in the application, but not outside the application.

11 NAME OF PRESENTATION [CHANGE IN SLIDE MASTER] MONTH, YEAR [CHANGE IN SLIDE MASTER] SQLite 11 SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.

12 NAME OF PRESENTATION [CHANGE IN SLIDE MASTER] MONTH, YEAR [CHANGE IN SLIDE MASTER] SQLite 12 Implements most of the SQL-92 standard for SQL but it lacks some features. 1.Partial support for triggers. 2.Can't write to views(delete,insert,update). 3.Can’t support full outer join, right outer join 4.Support limit to return records. 5.Case-sensitive

13 NAME OF PRESENTATION [CHANGE IN SLIDE MASTER] MONTH, YEAR [CHANGE IN SLIDE MASTER] SQLite  Create or Open database SQLiteDatabase openOrCreateDatabase (String name,int mode, SQLiteDatabase.CursorFactory factory) MODE_PRIVATE,MODE_WORLD_ READABLE,MODE_WORLD_WRITEABLE  Execute non-query SQL execSQL(String sql), support insert,update,delete,create,drop SQL.  Execute query SQL rawQuery(String sql), support select SQL.  Cursor to keep track of location within a resultset 13

14 NAME OF PRESENTATION [CHANGE IN SLIDE MASTER] MONTH, YEAR [CHANGE IN SLIDE MASTER] SQLite CRUD - SQLiteDatabase methods  public long insert (String table, String nullColumnHack, ContentValuesinitialValues).  delete(String table, String whereClause, String[] whereArgs)  query(String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit)  update(String table, ContentValues values, String whereClause, String[] whereArgs) 14

15 NAME OF PRESENTATION [CHANGE IN SLIDE MASTER] MONTH, YEAR [CHANGE IN SLIDE MASTER] SQLite Sample 15

16 NAME OF PRESENTATION [CHANGE IN SLIDE MASTER] MONTH, YEAR [CHANGE IN SLIDE MASTER] SQLite Sample 16

17 NAME OF PRESENTATION [CHANGE IN SLIDE MASTER] MONTH, YEAR [CHANGE IN SLIDE MASTER] 5. External Storage(SDCard and Network) 17  Store public data on the shared external storage.  This can be a removable storage media (such as an SD card) or an internal (non-removable) storage.

18 NAME OF PRESENTATION [CHANGE IN SLIDE MASTER] MONTH, YEAR [CHANGE IN SLIDE MASTER] SDCard Storage Sample 18 Activity- A, write data Activity- B, read data

19 NAME OF PRESENTATION [CHANGE IN SLIDE MASTER] MONTH, YEAR [CHANGE IN SLIDE MASTER] SDCard Storage Sample 19 /mnt/sdcard/sd.txt conclusion : you can write larger data to file. Such as a game application.

20 NAME OF PRESENTATION [CHANGE IN SLIDE MASTER] MONTH, YEAR [CHANGE IN SLIDE MASTER] Network Storage 20  Store data on the web with your own network server.  Web service, HTTP  java.net.* , Android.net.*

21 NAME OF PRESENTATION [CHANGE IN SLIDE MASTER] MONTH, YEAR [CHANGE IN SLIDE MASTER] Which is the best way to store it ? 21 1.How often will the data be accessed or updated? 2.The data is private? 3.Will the data be added to over time? 4.How will the data need to be used? 5.How much space your data requires?

22 NAME OF PRESENTATION [CHANGE IN SLIDE MASTER] MONTH, YEAR [CHANGE IN SLIDE MASTER] 22 © 2009 Moody’s Analytics, Inc. and/or its licensors and affiliates (collectively, “MOODY’S”). All rights reserved. ALL INFORMATION CONTAINED HEREIN IS PROTECTED BY COPYRIGHT LAW AND NONE OF SUCH INFORMATION MAY BE COPIED OR OTHERWISE REPRODUCED, REPACKAGED, FURTHER TRANSMITTED, TRANSFERRED, DISSEMINATED, REDISTRIBUTED OR RESOLD, OR STORED FOR SUBSEQUENT USE FOR ANY SUCH PURPOSE, IN WHOLE OR IN PART, IN ANY FORM OR MANNER OR BY ANY MEANS WHATSOEVER, BY ANY PERSON WITHOUT MOODY’S PRIOR WRITTEN CONSENT. All information contained herein is obtained by MOODY’S from sources believed by it to be accurate and reliable. Because of the possibility of human or mechanical error as well as other factors, however, all information contained herein is provided “AS IS” without warranty of any kind. Under no circumstances shall MOODY’S have any liability to any person or entity for (a) any loss or damage in whole or in part caused by, resulting from, or relating to, any error (negligent or otherwise) or other circumstance or contingency within or outside the control of MOODY’S or any of its directors, officers, employees or agents in connection with the procurement, collection, compilation, analysis, interpretation, communication, publication or delivery of any such information, or (b) any direct, indirect, special, consequential, compensatory or incidental damages whatsoever (including without limitation, lost profits), even if MOODY’S is advised in advance of the possibility of such damages, resulting from the use of or inability to use, any such information. The ratings, financial reporting analysis, projections, and other observations, if any, constituting part of the information contained herein are, and must be construed solely as, statements of opinion and not statements of fact or recommendations to purchase, sell or hold any securities. NO WARRANTY, EXPRESS OR IMPLIED, AS TO THE ACCURACY, TIMELINESS, COMPLETENESS, MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OF ANY SUCH RATING OR OTHER OPINION OR INFORMATION IS GIVEN OR MADE BY MOODY’S IN ANY FORM OR MANNER WHATSOEVER. Each rating or other opinion must be weighed solely as one factor in any investment decision made by or on behalf of any user of the information contained herein, and each such user must accordingly make its own study and evaluation of each security and of each issuer and guarantor of, and each provider of credit support for, each security that it may consider purchasing, holding, or selling.


Download ppt "Android Storage MAY 2013 Hu.Cai. NAME OF PRESENTATION [CHANGE IN SLIDE MASTER] MONTH, YEAR [CHANGE IN SLIDE MASTER] Outline 1.Storage In General 2.SharedPreferences."

Similar presentations


Ads by Google