SQLiteLog:(1) no such table: tableName.db (sqlite with android)

I want to use SQlite for my android app to store some data.After trying to run the app i got this error :



    06-21 16:14:30.175    2375-2375/snet.app E/SQLiteLog﹕ (1) no such table: tracks.db
06-21 16:14:30.176 2375-2375/snet.app E/SQLiteDatabase﹕ Error inserting title=Goldchains _id=null artist=Marlin album=Filet Mignon - Volume II
android.database.sqlite.SQLiteException: no such table: tracks.db (code 1): , while compiling: INSERT INTO tracks.db(title,_id,artist,album) VALUES (?,?,?,?)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1469)
at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1341)
at snet.tuberlin.app.DBHandler.addTrack(DBHandler.java:64)
at snet.tuberlin.app.TrackInformations$1.onReceive(TrackInformations.java:91)
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:866)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5257)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)


I tried everything that i found in google to resolve this including changing the database version.It works ones but after trying to run the app another time it went back to the same error.
This is my DBHandler class :



    public class DBHandler extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 6;// as you can see i changed the version many time already !!
private static final String DATABASE_NAME = "tracks.db";

public static final String TABLE_TRACKS = "tracks";
public static final String COLUMN_ID = "_id";
public static final String COLUMN_TITLE = "title";
public static final String COLUMN_ARTIST = "artist";
public static final String COLUMN_ALBUM = "album";
public static final String COLUMN_LOCATION = "location";

public DBHandler(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
super(context, DATABASE_NAME, factory, DATABASE_VERSION);
}

public void onCreate(SQLiteDatabase db) {

final String DATABASE_CREATE = "create table "
+ TABLE_TRACKS + "(" + COLUMN_ID
+ " integer primary key autoincrement, " + COLUMN_TITLE
+ " text not null, " +COLUMN_ARTIST
+ " text not null, " + COLUMN_ALBUM
+ " text not null);";
db.execSQL(DATABASE_CREATE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + TABLE_TRACKS);
onCreate(db);
}

/*Add new row to the DB*/
public void addTrack(UserTrack usertrack) {
ContentValues values = new ContentValues();
values.put(COLUMN_ID, usertrack.getUserTrackId());
values.put(COLUMN_TITLE, usertrack.getTitle());
values.put(COLUMN_ARTIST, usertrack.getArtist());
values.put(COLUMN_ALBUM, usertrack.getAlbum());

SQLiteDatabase db = getWritableDatabase();
db.insert(DATABASE_NAME, null, values);
db.close();
}


}


Answers

Just change to db.insert(TABLE_TRACKS, null, values); in addTrack method.



You have provided the db name instead of the table name, hence you are getting the error.



Corrected code below



public void addTrack(UserTrack usertrack) {
ContentValues values = new ContentValues();
values.put(COLUMN_ID, usertrack.getUserTrackId());
values.put(COLUMN_TITLE, usertrack.getTitle());
values.put(COLUMN_ARTIST, usertrack.getArtist());
values.put(COLUMN_ALBUM, usertrack.getAlbum());

SQLiteDatabase db = getWritableDatabase();
db.insert(TABLE_TRACKS, null, values); <----change here
db.close();
}




Track originating url for paypal payments

Ok, before i start i am not a developer and what i am looking for more than anything is to know if what i want is possible.



I want to know if there is a way to track the referring/original url for paypal payments.



We are working with a company with a huge user base, they are advertising a product that is payed for through paypal on our site. We need to know which users sign up coming from their site and which ones came in direct.



Ideally i only want to track once the payment is made.



Any advice would be greatly appreciated.



Answers

I am assuming this is Payments Standard.



If this is, you will need to pass that information as a CUSTOM value in your HTML form 9or via the custom button system). This value will be passed back to you via IPN.





html page can not find angular

I have the below code in a html page, running it though I keep getting an error stating that "angular is not defined" I have included angular in the head so i'm not sure why it can't locate it, the url to angular i'm also able to hit directly.





<!DOCTYPE>
<html ng-app="test">
<head>
<title>
<script src="https://code.angularjs.org/1.2.25/angular.js"></script>
</title>
</head>
<body ng-controller="TestController">

<form name="CopyFile" ng-submit="copy(fileId)">
<input type="text" ng-model="fileId"/>
<input type="submit" value="Copy"/>
</form>

<div>{{ message }}</div>

<div>{{ error }}</div>

<script type="text/javascript">

(function () {

var app = angular.module("test", []);

var testController = function ($scope, $http) {

$scope.copy = function (fileId) {
$http.get("http://localhost/test/copy/prod.aspx/ToProd?fileId=" + fileId)
.then(onComplete, onError);
};

var onComplete = function (response) {
$scope.message = response;
};

var onError = function (reason) {
$scope.error = "File could not be copied " + reason;
};
};

app.controller("TestController", ["$scope", "$http"], testController);

} ());

</script>

</body>
</html>


Answers

This may not be the cause but you don't want your angular include inside of your title. It should be something more like this:



<!DOCTYPE>
<html ng-app="test">
<head>
<title>My Page</title>
<script src="https://code.angularjs.org/1.2.25/angular.js"></script>
</head>
.....


Answers

You gave <script> inside <title>?



<title>
<script src="https://code.angularjs.org/1.2.25/angular.js"></script>
</title>


Please remove it outside.





↑このページのトップヘ