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
import android.content.Intent; | |
import android.os.Bundle; | |
import android.support.v7.app.AppCompatActivity; | |
import android.view.View; | |
import android.widget.ArrayAdapter; | |
import android.widget.Button; | |
import android.widget.ListView; | |
public class TransitionThemeActivity extends AppCompatActivity implements View.OnClickListener { |
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
package com.example.AppName.new_package_name; | |
import android.provider.BaseColumns; | |
public final class ContractClass { | |
// content Uri | |
public static final String CONTENT_AUTHORITY = "com.example.android.AppName"; | |
public static final Uri BASE_CONTENT_URI = Uri.parse("content://" + CONTENT_AUTHORITY); | |
public static final String PATH_WORDS = "words"; |
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 HelperClass extends SQLiteOpenHelper { | |
//Name of the database | |
private static final String DATABASE_NAME = "DBName.db"; | |
//DB Version | |
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 MainActivity extends AppCompatActivity { | |
private HelperClass mHelper; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
mHelper = new HelperClass(this); |
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 AppProvider extends ContentProvider { | |
private HelperClass mDbHelper; | |
@Override | |
public boolean onCreate() { | |
mDbHelper = new HelperClass(getContext()); | |
return true; | |
} |
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
<provider | |
android:authorities="com.example.android.AppName" | |
android:name=".Data.AppProvider" | |
android:exported="false" /> |
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 AppProvider extends ContentProvider { | |
private static final UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH); | |
static { | |
/* | |
* The calls to addURI() go here, for all of the content URI patterns that the provider | |
* should recognize. For this snippet, only the calls for table 3 are shown. | |
*/ |
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 Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, | |
String sortOrder) { | |
// Get readable database | |
SQLiteDatabase database = mDbHelper.getReadableDatabase(); | |
// This cursor will hold the result of the query | |
Cursor cursor=null; | |
// Figure out if the URI matcher can match the URI to a specific code |
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
... | |
@Nullable | |
@Override | |
public Uri insert(@NonNull Uri uri, @Nullable ContentValues contentValues) { | |
final int match = uriMatcher.match(uri); | |
switch (match){ | |
case WORDS_CODE : | |
return insertData(uri, contentValues); | |
default: |
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 void insertData() { | |
ContentValues values = new ContentValues(); | |
values.put(Words.COLUMN_WORD, "Test Word"); | |
values.put(Words.COLUMN_WORD_T, "Test T Word"); | |
values.put(Words.COLUMN_WORD_T2, "Test T2 Word"); | |
values.put(Words.COLUMN_WORD_T3, "Test T3 Word"); | |
values.put(Words.COLUMN_ARTIKEL, Words.ARTIKEL_UNKNOWN); | |
Uri newURI = getContentResolver().insert(DeutchVContract.CONTENT_URI, values); | |
if (newURI != null) { |
OlderNewer