This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* create custom DatabaseHelper class that extends SQLiteOpenHelper | |
*/ | |
public class DatabaseHelper extends SQLiteOpenHelper { | |
private static DatabaseHelper mInstance = null; | |
private static final String DATABASE_NAME = "databaseName"; | |
private static final String DATABASE_TABLE = "tableName"; | |
private static final int DATABASE_VERSION = 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainApplication extends Application { | |
/** | |
* see NotePad tutorial for an example implementation of DataDbAdapter | |
*/ | |
private static DataDbAdapter mDbHelper; | |
/** | |
* Called when the application is starting, before any other | |
* application objects have been created. Implementations |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyFragment { | |
/** | |
* Make the default constructor private to prevent direct | |
* instantiation. Now all instances of this class must be | |
* instantiated with a call to newInstance(). | |
*/ | |
private MyFragment() { } | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Singleton { | |
private static final Singleton instance = null; | |
/** | |
* Make the class private to prevent direct instantiation. | |
* this forces clients to call newInstance(), which will | |
* ensure the class' Singleton property. | |
*/ | |
private Singleton() { } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SampleActivity extends Activity { | |
/** | |
* A string constant to use in calls to the "log" methods. Its | |
* value is often given by the name of the class, as this will | |
* allow you to easily determine where log methods are coming | |
* from when you analyze your logcat output. | |
*/ | |
private static final String TAG = "SampleActivity"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CompatibilityUtil { | |
/** | |
* Get the current Android API level. | |
*/ | |
public static int getSdkVersion() { | |
return Build.VERSION.SDK_INT; | |
} | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class AlbumStorageDirFactory { | |
/** | |
* Returns a File object that points to the folder that will store | |
* the album's pictures. | |
*/ | |
public abstract File getAlbumStorageDir(String albumName); | |
/** | |
* A static factory method that returns a new AlbumStorageDirFactory |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BaseAlbumDirFactory extends AlbumStorageDirFactory { | |
/** | |
* For pre-Froyo devices, we must provide the name of the photo directory | |
* ourselves. We choose "/dcim/" as it is the widely considered to be the | |
* standard storage location for digital camera files. | |
*/ | |
private static final String CAMERA_DIR = "/dcim/"; | |
@Override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FroyoAlbumDirFactory extends AlbumStorageDirFactory { | |
@Override | |
public File getAlbumStorageDir(String albumName) { | |
return new File( | |
Environment.getExternalStoragePublicDirectory( | |
Environment.DIRECTORY_PICTURES | |
), | |
albumName | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SampleActivity extends Activity { | |
private AlbumStorageDirFactory mAlbumFactory; | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
/* Implementation not shown */ |
OlderNewer