Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.83 KB | None | 0 0
  1. <provider android:name="NaTempsProvider"
  2. android:authorities="com.sdnsoft.natemps.natemps.data.NaTempsProvider.provider"
  3. android:exported="false"
  4. android:enabled="true">
  5. <grant-uri-permission android:pathPattern=".*" />
  6. </provider>
  7.  
  8. public class NaTempsContract {
  9. public static final String AUTHORITY = "com.sdnsoft.natemps.natemps.data.NaTempsProvider.provider";// This class cannot be instantiated
  10. private NaTempsContract() {
  11. }
  12.  
  13. public static final class app_role implements BaseColumns {
  14.  
  15. // This class cannot be instantiated
  16. private app_role() {
  17. }
  18.  
  19. /**
  20. * The table name offered by this provider
  21. */
  22. public static final String TABLE_NAME = "app_role";
  23.  
  24. /*
  25. * URI definitions
  26. */
  27.  
  28. /**
  29. * The scheme part for this provider's URI
  30. */
  31. private static final String SCHEME = "content://";
  32.  
  33.  
  34. /**
  35. * Path part for the app_role URI
  36. */
  37. private static final String PATH_APP_ROLE = "/app_role";
  38.  
  39. /**
  40. * Path part for the app_role ID URI
  41. */
  42. private static final String PATH_APP_ROLE_ID = "/app_role/";
  43.  
  44. /**
  45. * The content:// style URL for this table
  46. */
  47. public static final Uri CONTENT_URI = Uri.parse(SCHEME + AUTHORITY + PATH_APP_ROLE);
  48.  
  49.  
  50. /**
  51. * The default sort order for this table
  52. */
  53. public static final String DEFAULT_SORT_ORDER = "name DESC";
  54.  
  55.  
  56. /*
  57. * Column definitions
  58. */
  59.  
  60. /**
  61. * <P>Type: INTEGER</P>
  62. */
  63. public static final String COLUMN_NAME_ID = "id";
  64.  
  65. /**
  66. * <P>Type: TEXT</P>
  67. */
  68. public static final String COLUMN_NAME_NAME = "name";
  69.  
  70. /**
  71. * <P>Type: TEXT</P>
  72. */
  73. public static final String COLUMN_NAME_DISPLAY_NAME = "display_name";
  74.  
  75. }}
  76.  
  77. public class NaTempsProvider
  78. extends ContentProvider implements ContentProvider.PipeDataWriter<Cursor> { // Used for debugging and loggingprivate static final String TAG = "NaTempsProvider";
  79.  
  80. private static final int DATABASE_VERSION = 1;
  81.  
  82.  
  83. // Handle to a new DatabaseHelper.
  84. private DatabaseHelper mOpenHelper;
  85.  
  86. static class DatabaseHelper extends SQLiteOpenHelper {
  87. DatabaseHelper(Context context) {
  88.  
  89. // calls the super constructor, requesting the default cursor factory.
  90. super(context, DATABASE_NAME, null, DATABASE_VERSION);
  91. } // all type into database
  92.  
  93. public static final String PRIMARY_KEY_TYPE = " INTEGER PRIMARY KEY AUTOINCREMENT ";
  94. // Structure de la table `app_role`
  95.  
  96. public static final String APP_ROLE_TABLE_NAME = "app_role";
  97. public static final String APP_ROLE_PRIMARY_KEY = "id";
  98.  
  99. public static final String APP_ROLE_NAME = "name";
  100. public static final String APP_ROLE_DISPLAY_NAME = "display_name";
  101. public static final String APP_ROLE_CREATE =
  102. "CREATE TABLE " + APP_ROLE_TABLE_NAME + " (" +
  103. APP_ROLE_PRIMARY_KEY + PRIMARY_KEY_TYPE + "," +
  104. APP_ROLE_NAME + " TEXT," +
  105. APP_ROLE_DISPLAY_NAME +
  106. " TEXT);INSERT INTO `app_role` (`id`, `name`, `display_name`) VALUESn" +
  107. "(1, 'accueil', 'Accueil'),n" +
  108. "(2, 'responsable_cercle', 'responsable de cercle');n";
  109.  
  110.  
  111. public static final String APP_ROLE_TABLE_DROP = "DROP TABLE IF EXISTS " + APP_ROLE_TABLE_NAME + ";";
  112.  
  113. @Override
  114. public void onCreate(SQLiteDatabase db) {
  115. db.execSQL(
  116. APP_ROLE_CREATE
  117. );
  118. }
  119.  
  120. @Override
  121. public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
  122. db.execSQL(
  123. APP_ROLE_TABLE_DROP
  124. );
  125. onCreate(db);
  126. }
  127.  
  128. }
  129.  
  130. @Override
  131. public boolean onCreate() {
  132.  
  133. // Creates a new helper object. Note that the database itself isn't opened until
  134. // something tries to access it, and it's only created if it doesn't already exist.
  135. mOpenHelper = new DatabaseHelper(getContext());
  136.  
  137. // Assumes that any failures will be reported by a thrown exception.
  138. return true;
  139. }
  140. ...}
  141.  
  142. // If there is no data associated with the Intent, sets the data to the default URI, which
  143. // accesses a list of notes.
  144. if (intent.getData() == null) {
  145. intent.setData(NaTempsContract.app_role.CONTENT_URI);
  146. }
  147.  
  148. /* Performs a managed query. The Activity handles closing and requerying the cursor
  149. * when needed.
  150. *
  151. * Please see the introductory note about performing provider operations on the UI thread.
  152. */
  153. Cursor cursor = managedQuery(
  154. getIntent().getData(), // Use the default content URI for the provider.
  155. NaTempsProjections.APP_ROLE_PROJECTION, // Return the note ID and title for each note.
  156. null, // No where clause, return all records.
  157. null, // No where clause, therefore no where column values.
  158. null // Use the default sort order.
  159. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement