Advertisement
Guest User

Untitled

a guest
Feb 13th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.66 KB | None | 0 0
  1. import android.content.ContentResolver;
  2. import android.net.Uri;
  3. import android.provider.BaseColumns;
  4.  
  5. /**
  6.  * Created by wenceslaus on 06.11.16.
  7.  */
  8.  
  9. public class NotesTable implements Table {
  10.  
  11.     public static final String NAME = "notes";
  12.  
  13.     public static final String CREATE = "CREATE TABLE "
  14.             + NAME
  15.             + "("
  16.             + Columns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
  17.             + Columns.TITLE + " TEXT, "
  18.             + Columns.TEXT + " TEXT "
  19.             + ");";
  20.  
  21.     public static final String DROP = "DROP TABLE IF EXISTS " + NAME;
  22.  
  23.     private static final String MIME_TYPE = "vnd." + BuildConfig.AUTHORITY + "_" + NAME;
  24.  
  25.     private static final String CONTENT_PATH = "content://" + BuildConfig.AUTHORITY + "/" + NAME;
  26.  
  27.     public static final Uri CONTENT_URI = Uri.parse(CONTENT_PATH);
  28.  
  29.     @Override
  30.     public String getName() {
  31.         return NAME;
  32.     }
  33.  
  34.     @Override
  35.     public String getColumnId() {
  36.         return Columns._ID;
  37.     }
  38.  
  39.     public String getContentItemType() {
  40.         return ContentResolver.CURSOR_ITEM_BASE_TYPE + "/" + MIME_TYPE;
  41.     }
  42.  
  43.     public String getContentType() {
  44.         return ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + MIME_TYPE;
  45.     }
  46.  
  47.     public Uri getItemUri(long id) {
  48.         return Uri.parse(CONTENT_PATH + "/" + id);
  49.     }
  50.  
  51.     public interface Columns extends BaseColumns {
  52.         String TITLE = "title";
  53.         String TEXT = "text";
  54.     }
  55.  
  56.     public interface ColumnIndices {
  57.         int _ID = 0;
  58.         int TITLE = 1;
  59.         int TEXT = 2;
  60.     }
  61.  
  62.     public interface Selection {
  63.         String USER_ID = Columns.TITLE + " = ?";
  64.     }
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement